Skip to content

ICE when using slicing syntax with invalid code #20614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
quantheory opened this issue Jan 6, 2015 · 2 comments · Fixed by #20897
Closed

ICE when using slicing syntax with invalid code #20614

quantheory opened this issue Jan 6, 2015 · 2 comments · Fixed by #20897
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@quantheory
Copy link
Contributor

While trying to grok/update some old code, I found that an ICE occurs in the following (invalid) code:

#![feature(slicing_syntax)]
#![feature(unboxed_closures)]

#![crate_type = "lib"]

use std::cell::RefCell;
use std::sync::Mutex;

pub struct InductionSeq<T> {
    recursor: fn(&[T]) -> T,
    cache: Mutex<RefCell<Vec<T>>>,
}

impl<T> InductionSeq<T> {
    fn grow_cache_one(&self) {
        let mut cache = self.cache.lock().unwrap().borrow_mut();
        let recursor: Box<Fn(&[T]) -> T> = box self.recursor;
        let new_item = recursor.call((cache[],));
    }
}

The error/output:

inf_seq.rs:18:36: 18:42 error: type `std::sync::mutex::Mutex<core::cell::RefCell<collections::vec::Vec<T>>>` does not implement any method in scope named `lock`
inf_seq.rs:18         let mut cache = self.cache.lock().unwrap().borrow_mut();
                                                 ^~~~~~
error: internal compiler error: no type for node 68: expr  (id=68) in fcx 0x30a517e51f8
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:      0x30a593d22d0 - sys::backtrace::write::h8532e701ef86014f4it
   2:      0x30a593f7b00 - failure::on_fail::h7532e1f79d134d5dzvz
   3:      0x30a5935d1c0 - rt::unwind::begin_unwind_inner::h97b151606151d62deaz
   4:      0x30a5422fc60 - rt::unwind::begin_unwind::h15809447133099964284
   5:      0x30a54230510 - diagnostic::Handler::bug::h8818b567cf47e6a0DLF
   6:      0x30a5756acf0 - session::Session::bug::h251da16737c526c0lrq
   7:      0x30a58990ec0 - check::FnCtxt<'a, 'tcx>::node_ty::h8b4513e3177b34b9FAl
   8:      0x30a589a6390 - check::writeback::WritebackCx<'cx, 'tcx>::visit_node_id::hadb4e437b164af77oDb
   9:      0x30a589a2620 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h773756089457ec03otb
  10:      0x30a589a2620 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h773756089457ec03otb
  11:      0x30a589a2620 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h773756089457ec03otb
  12:      0x30a589a6290 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_block::h73bb9a8ed95e2890Dub
  13:      0x30a58a76b40 - check::check_bare_fn::h592fda8aa741d710Qtj
  14:      0x30a58a7cf70 - check::check_method_body::ha0d2d56085b511095Vj
  15:      0x30a58a6e170 - check::check_item::h9827005a9cde6421CMj
  16:      0x30a58c0efe0 - check_crate::unboxed_closure.40162
  17:      0x30a58c09c30 - check_crate::h19fb6dea5733566ajsx
  18:      0x30a59923640 - driver::phase_3_run_analysis_passes::h46b1604d9f9f5633Tva
  19:      0x30a59911ae0 - driver::compile_input::h68b8602933aad8d7wba
  20:      0x30a599dceb0 - thunk::F.Invoke<A, R>::invoke::h18029802347644288836
  21:      0x30a599dbc60 - rt::unwind::try::try_fn::h6518866316425934196
  22:      0x30a5945e400 - rust_try_inner
  23:      0x30a5945e3f0 - rust_try
  24:      0x30a599dbfb0 - thunk::F.Invoke<A, R>::invoke::h15513809553472565307
  25:      0x30a593e3e40 - sys::thread::thread_start::h5ea7ba97235331d5a9v
  26:      0x30a53a541a0 - <unknown>
  27:      0x30a590142b9 - clone
  28:                0x0 - <unknown>
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 6, 2015
@drawoc
Copy link

drawoc commented Jan 6, 2015

I also ran into the same panic while updating old code.

Here's some simpler code that also triggers the panic:

fn main() {
    let string = String::new();
    string.foo()[0];
}

(I think the panic only happens when the method is undefined, so if foo were implemented on String, I think it would not ice.)

This gives me:

$ rustc src/main.rs 
src/main.rs:3:12: 3:17 error: type `collections::string::String` does not implement any method in scope named `foo`
src/main.rs:3     string.foo()[0];
                         ^~~~~
error: internal compiler error: no type for node 17: expr 0 (id=17) in fcx 0x7f369a7ec488
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:     0x7f36a22cdd10 - sys::backtrace::write::hde9d0c7005312c09CQs
   2:     0x7f36a22f3a60 - failure::on_fail::h6fe6edb8db0347b4e3y
   3:     0x7f36a2259890 - rt::unwind::begin_unwind_inner::h59b1686c02dda4e3VHy
   4:     0x7f369d1e9e30 - rt::unwind::begin_unwind::h12162784926453586192
   5:     0x7f369d1ea6e0 - diagnostic::Handler::bug::haaef3c02788d02f80qF
   6:     0x7f36a05500a0 - session::Session::bug::hb63dd294b5253b83BWp
   7:     0x7f36a19c2b60 - check::FnCtxt<'a, 'tcx>::node_ty::hb6cac7314f203334Rzl
   8:     0x7f36a19d8090 - check::writeback::WritebackCx<'cx, 'tcx>::visit_node_id::h1d3427de52b65854pDb
   9:     0x7f36a19d4320 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h080cb55b8711012fptb
  10:     0x7f36a19d7f90 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_block::h31a05e2e23ab63c1Eub
  11:     0x7f36a1a740d0 - check::check_bare_fn::h722855d499a8f8782sj
  12:     0x7f36a1a6b820 - check::check_item::h24b59d262c9736e5OLj
  13:     0x7f36a1b60310 - check_crate::unboxed_closure.39887
  14:     0x7f36a1b5af50 - check_crate::h47b99cd0e2ad3eb1amx
  15:     0x7f36a280f3e0 - driver::phase_3_run_analysis_passes::h19c1c734b891aff0Sva
  16:     0x7f36a27fd910 - driver::compile_input::h5b791fe2c3c1b976vba
  17:     0x7f36a28c49c0 - thunk::F.Invoke<A, R>::invoke::h13644216210312096233
  18:     0x7f36a28c3770 - rt::unwind::try::try_fn::h9904251112696932147
  19:     0x7f36a2357fa0 - rust_try_inner
  20:     0x7f36a2357f90 - rust_try
  21:     0x7f36a28c3ac0 - thunk::F.Invoke<A, R>::invoke::h8809310375033820670
  22:     0x7f36a22df890 - sys::thread::thread_start::h0ee022c3d5527b83IGv
  23:     0x7f369ca0e250 - start_thread
  24:     0x7f36a1f14219 - clone
  25:                0x0 - <unknown>

Rust version:

$ rustc --version --verbose
rustc 0.13.0-nightly (c7dd3c4d6 2015-01-05 23:51:00 +0000)
binary: rustc
commit-hash: c7dd3c4d69aee1c4ad8cc220c194b176bba2ab62
commit-date: 2015-01-05 23:51:00 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly

@tshakah
Copy link
Contributor

tshakah commented Jan 7, 2015

Getting the same problem - also because of an undefined method (spelt the method name wrong and got the ICE, fixed the spelling and no ICE)

barosl added a commit to barosl/rust that referenced this issue Jan 11, 2015
If the type of a node cannot be determined due to a previous type error,
a "no type for node" ICE occurs. This commit makes it return ty_err
instead in such a case.

Fixes rust-lang#20401.
Fixes rust-lang#20506.
Fixes rust-lang#20614.
Fixes rust-lang#20752.
Fixes rust-lang#20829.
Fixes rust-lang#20846.
Fixes rust-lang#20885.
Fixes rust-lang#20886.
bors added a commit that referenced this issue Jan 12, 2015
If the type of a node cannot be determined due to a previous type error, a `no type for node` ICE occurs. This commit makes it return `ty_err` instead in such a case.

Fixes #20401.
Fixes #20506.
Fixes #20614.
Fixes #20752.
Fixes #20829.
Fixes #20846.
Fixes #20885.
Fixes #20886.
Fixes #20952.
Fixes #20970.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants