Skip to content

Internal compiler error "node_id_to_type: no type for node" with save-analysis #37323

Closed
@evestera

Description

@evestera

Compiling the code below with rustc point2.rs -Zsave-analysis resulted in an internal compiler error.

I've tried to minimize the code. Removing either the derive, the other two structs or fixing the lifetime error in NestedA makes the panic disappear.

Code

#[derive(Debug)]
struct Point {
}

struct NestedA<'a, 'b> {
    x: &'a NestedB<'b>
}

struct NestedB<'a> {
    x: &'a i32,
}

fn main() {
}

Output with backtrace

error[E0491]: in type `&'a mut NestedB<'b>`, reference has a longer lifetime than the data it references
 --> point2.rs:6:5
  |
6 |     x: &'a mut NestedB<'b>
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
note: the pointer is valid for the lifetime 'a as defined on the struct at 5:0
 --> point2.rs:5:1
  |
5 | struct NestedA<'a, 'b> {
  | ^
note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 5:0
 --> point2.rs:5:1
  |
5 | struct NestedA<'a, 'b> {
  | ^

error: internal compiler error: ../src/librustc/ty/mod.rs:2097: node_id_to_type: no type for node `pat Point {  } (id=46)`

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:656
stack backtrace:
   1:        0x106869608 - std::sys::backtrace::tracing::imp::write::h22f199c1dbb72ba2
   2:        0x106876f2f - std::panicking::default_hook::{{closure}}::h9a389c462b6a22dd
   3:        0x106874355 - std::panicking::default_hook::h852b4223c1c00c59
   4:        0x106874a76 - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   5:        0x1067425da - std::panicking::begin_panic::h2f463d37998ebeba
   6:        0x10675294a - rustc_errors::Handler::bug::haca77c19c882b432
   7:        0x1036f72cc - rustc::session::opt_span_bug_fmt::{{closure}}::hfeb850fbe828b399
   8:        0x1036298c9 - rustc::session::opt_span_bug_fmt::h46e45438a860a75e
   9:        0x10362967a - rustc::session::bug_fmt::hde22f071bf5a80ea
  10:        0x1036ac0e5 - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::node_id_to_type::h73d18361623a52d0
  11:        0x1032b8264 - <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, D>>::process_pat::h3b459ce9f62d7503
  12:        0x103292ace - syntax::visit::walk_expr::h740e88e7b04dea4f
  13:        0x1032ae27e - <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, D>>::process_method::h4f6b66158471b107
  14:        0x1032bcc29 - <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, D>>::process_impl_item::h48d1756270c266fa
  15:        0x1032d49b5 - <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, D> as syntax::visit::Visitor>::visit_item::hfd68472f19fd8d39
  16:        0x1032ee1ca - rustc_save_analysis::process_crate::h2b636e6f9af828ac
  17:        0x10272769b - <rustc_driver::RustcDefaultCalls as rustc_driver::CompilerCalls<'a>>::build_controller::{{closure}}::{{closure}}::hcab3ae4dff1970b7
  18:        0x10272c4a1 - <rustc_driver::RustcDefaultCalls as rustc_driver::CompilerCalls<'a>>::build_controller::{{closure}}::h146db60594d89824
  19:        0x102728b0f - rustc_driver::driver::compile_input::{{closure}}::h9162a2fa292aeb3f
  20:        0x10271c513 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h1928c4704cfe9c61
  21:        0x1026f0284 - rustc_driver::driver::phase_3_run_analysis_passes::he578df6b8805151c
  22:        0x1026d952a - rustc_driver::driver::compile_input::h5b63ccd49eeeb98b
  23:        0x102702789 - rustc_driver::run_compiler::h98c7274e7cb1d11d
  24:        0x102643558 - std::panicking::try::do_call::h99ed0da044e497c3
  25:        0x1068774ea - __rust_maybe_catch_panic
  26:        0x102661dcf - <F as alloc::boxed::FnBox<A>>::call_box::hbdd5a14cd8e33b97
  27:        0x106873624 - std::sys::thread::Thread::new::thread_start::h50b05608a499d2b2
  28:     0x7fff8e037059 - _pthread_body
  29:     0x7fff8e036fd6 - _pthread_start

Meta

rustc 1.14.0-nightly (16eeeac78 2016-10-18)
binary: rustc
commit-hash: 16eeeac783d2ede28e09f2a433c612dea309fe33
commit-date: 2016-10-18
host: x86_64-apple-darwin
release: 1.14.0-nightly
LLVM version: 3.9

Also occurs with stable (but exact output above is from nightly):

rustc 1.12.1 (d4f39402a 2016-10-19)
binary: rustc
commit-hash: d4f39402a0c2c2b94ec0375cd7f7f6d7918113cd
commit-date: 2016-10-19
host: x86_64-apple-darwin
release: 1.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions