Skip to content

internal compiler error: Explicit deref of non-derefable type #18767

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
mpdn opened this issue Nov 8, 2014 · 4 comments
Closed

internal compiler error: Explicit deref of non-derefable type #18767

mpdn opened this issue Nov 8, 2014 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mpdn
Copy link
Contributor

mpdn commented Nov 8, 2014

This code:

struct Obj {
    val: uint
}

fn main() {
    let mut v = Vec::from_fn(10, |val| { box Obj { val: val } });
    for &box Obj{ val } in v.iter_mut() {
        print!("{} ", val);
    }
}

Produces this error:

test.rs:7:10: 7:24 error: internal compiler error: Explicit deref of non-derefable type: core::slice::MutItems<'_, Box<Obj>>
test.rs:7     for &box Obj{ val } in v.iter_mut() {
                   ^~~~~~~~~~~~~~
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
task 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:116

stack backtrace:
   1:     0x7fe9623b5820 - rt::backtrace::imp::write::h8a05a2225574bd5ascq
   2:     0x7fe9623b88a0 - failure::on_fail::h3903c5b5788bc95c3xq
   3:     0x7fe966901a00 - unwind::begin_unwind_inner::h0919efe752d6fd357Rd
   4:     0x7fe962f00e40 - unwind::begin_unwind::h12448235468951990776
   5:     0x7fe962f00dc0 - diagnostic::SpanHandler::span_bug::h05cbb84cec88209aH6F
   6:     0x7fe967441dc0 - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_pattern::h9835242038117336796
   7:     0x7fe967441dc0 - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_pattern::h9835242038117336796
   8:     0x7fe967427c50 - middle::typeck::check::regionck::visit_expr::hc11c82b86d414b0eRjQ
   9:     0x7fe967424ef0 - middle::typeck::check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h403501b853f10cf3oUP
  10:     0x7fe967424e10 - middle::typeck::check::regionck::regionck_fn::he4ec90d3d42a3075QMP
  11:     0x7fe967473280 - middle::typeck::check::check_bare_fn::h95ab28fb77469556UhW
  12:     0x7fe96746f380 - middle::typeck::check::check_item::h2b8f33a3313a08a03BW
  13:     0x7fe967473030 - middle::typeck::check::check_item_types::h84bf484ad40a8c564gW
  14:     0x7fe966f62bc0 - util::common::time::h6545073167695776246
  15:     0x7fe96775a8d0 - middle::typeck::check_crate::h0f9c9a0fae05a0bfJEp
  16:     0x7fe9677c3940 - driver::driver::phase_3_run_analysis_passes::h46245b66b26614aeJoC
  17:     0x7fe9677be7a0 - driver::driver::compile_input::he3b1257e173b8860u5B
  18:     0x7fe967841900 - driver::run_compiler::hd836d04808dd8d5eLVF
  19:     0x7fe9678417f0 - driver::run::closure.146540
  20:     0x7fe966f7bb00 - task::TaskBuilder<S>::try_future::closure.104852
  21:     0x7fe966f7b8f0 - task::TaskBuilder<S>::spawn_internal::closure.104823
  22:     0x7fe966c48630 - task::NativeSpawner.Spawner::spawn::closure.8456
  23:     0x7fe9669568c0 - rust_try_inner
  24:     0x7fe9669568b0 - rust_try
  25:     0x7fe9668ff380 - unwind::try::h32143614f9ac9c88PGd
  26:     0x7fe9668ff210 - task::Task::run::h8c90cb04437a131dFMc
  27:     0x7fe966c48370 - task::NativeSpawner.Spawner::spawn::closure.8394
  28:     0x7fe966900a20 - thread::thread_start::h7bbfc46247c32113U7c
  29:     0x7fe961767250 - start_thread
  30:     0x7fe9665db3b9 - clone
  31:                0x0 - <unknown>
@eddyb
Copy link
Member

eddyb commented Nov 8, 2014

I'm amazed this doesn't go wrong more often.
Likely responsible for #17068.

@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 8, 2014
@bkoropoff
Copy link
Contributor

Yeah, that doesn't look right...

bkoropoff added a commit to bkoropoff/rust that referenced this issue Nov 8, 2014
@nikomatsakis
Copy link
Contributor

I'll fix this at some point soon if nobody else gets around to it.

@nikomatsakis
Copy link
Contributor

Oh, damn github, I should remember to refresh my tabs. Thanks @bkoropoff

bors added a commit that referenced this issue Nov 9, 2014
Use the mem-cat of the iterator element type rather than the iterator itself when processing the for loop pattern.

Closes #17068
Closes #18767
@bors bors closed this as completed in fbc2e92 Nov 10, 2014
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.

5 participants