Repository navigation
“Let NullaryConstructor = something;” causes internal compiler error: “tried to overwrite interned AdtDef” #37026
Copy link
Copy link
Closed
Labels
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
I was trying an if let pattern match for a nullary constructor like this:
if let Some(::router::NoRoute) = err.error.downcast() {
…
}but the compiler choked on the pattern match in an unexpected way. The fact that it's qualified does not seem to matter. See minimal repro below.
I tried this code:
extern crate router;
fn test() {
let router::NoRoute = (); // NoRoute is an empty struct in “router”
}I expected to see this happen:
An plain, ordinary, not-scary type error.
Instead, this happened:
error: internal compiler error: src/librustc/ty/context.rs:604: Tried to overwrite interned AdtDef: router::NoRoute
note: the compiler unexpectedly panicked. this is a bug.
Meta
rustc --version --verbose:
rustc 1.12.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.12.0
Backtrace:
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:634
stack backtrace:
1: 0x7f3f96d52cd9 - std::sys::backtrace::tracing::imp::write::h00e948915d1e4c72
2: 0x7f3f96d6351c - std::panicking::default_hook::_{{closure}}::h7b8a142818383fb8
3: 0x7f3f96d61914 - std::panicking::default_hook::h41cf296f654245d7
4: 0x7f3f96d62078 - std::panicking::rust_panic_with_hook::h4cbd7ca63ce1aee9
5: 0x7f3f906c7747 - std::panicking::begin_panic::hd3e81d866d6c5b0a
6: 0x7f3f906d8325 - rustc_errors::Handler::bug::h60f29cdeff67c1a3
7: 0x7f3f93fe74e4 - rustc::session::opt_span_bug_fmt::_{{closure}}::ha1319a72e07cd73b
8: 0x7f3f93f289d5 - rustc::session::opt_span_bug_fmt::h4badbc71bfeea6f9
9: 0x7f3f93f28812 - rustc::session::bug_fmt::he780dcb9e1e8a7d5
10: 0x7f3f93f9eabc - rustc::ty::context::TyCtxt::insert_adt_def::hf29e70e1fbb3e0ab
11: 0x7f3f9464b4f5 - rustc_metadata::decoder::get_adt_def::h78248c8ed76d9698
12: 0x7f3f9466a294 - rustc_metadata::csearch::_<impl rustc..middle..cstore..CrateStore<'tcx> for rustc_metadata..cstore..CStore>::adt_def::h9010a99ee3288f01
13: 0x7f3f93fc9477 - rustc::ty::_<impl rustc..ty..context..TyCtxt<'a, 'gcx, 'tcx>>::lookup_adt_def_master::h9f53a256095087eb
14: 0x7f3f93fc9985 - rustc::ty::_<impl rustc..ty..context..TyCtxt<'a, 'gcx, 'tcx>>::lookup_adt_def::h4a8f88c8263367bd
15: 0x7f3f9462afd9 - rustc_metadata::tydecode::TyDecoder::parse_ty::h2699ee85579ac86e
16: 0x7f3f9462a8a0 - rustc_metadata::tydecode::TyDecoder::parse_ty::h2699ee85579ac86e
17: 0x7f3f9464c48d - rustc_metadata::decoder::get_type::h6f6b706ba668663d
18: 0x7f3f94669f3f - rustc_metadata::csearch::_<impl rustc..middle..cstore..CrateStore<'tcx> for rustc_metadata..cstore..CStore>::item_type::h503a61f838833975
19: 0x7f3f93fc80fd - rustc::ty::_<impl rustc..ty..context..TyCtxt<'a, 'gcx, 'tcx>>::lookup_item_type::h32494593dee57ed3
20: 0x7f3f9535f985 - rustc_typeck::check::_match::_<impl rustc_typeck..check..FnCtxt<'a, 'gcx, 'tcx>>::check_pat::hb595ae90c56692e6
21: 0x7f3f953feb43 - rustc_typeck::check::FnCtxt::check_decl_local::h3566652c6c4664a1
22: 0x7f3f953fec7e - rustc_typeck::check::FnCtxt::check_stmt::h012039db8f7fe2ee
23: 0x7f3f953fefe7 - rustc_typeck::check::FnCtxt::check_block_with_expected::h6457d67c748c48f5
24: 0x7f3f953cc1a1 - rustc_typeck::check::check_fn::h116c7bc1c461e3a6
25: 0x7f3f953ca5d5 - rustc_typeck::check::check_bare_fn::haaae113cd154037a
26: 0x7f3f953ce741 - rustc_typeck::check::check_item_body::h169c2400d0395b3e
27: 0x7f3f953c7308 - rustc_typeck::check::check_item_bodies::h3f9ccb4bec3365b2
28: 0x7f3f95448293 - rustc_typeck::check_crate::h5c76faa7ac951c22
29: 0x7f3f9713da33 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::he5bb0058670d90b6
30: 0x7f3f9708e9f8 - rustc::ty::context::TyCtxt::create_and_enter::h1ad8faffb62f0367
31: 0x7f3f970f70bf - rustc_driver::driver::compile_input::h4d6bc655b7baad10
32: 0x7f3f97124016 - rustc_driver::run_compiler::h9165e61fc2dd486f
33: 0x7f3f9706af82 - std::panicking::try::do_call::hc52dd3bdae996640
34: 0x7f3f96d6f936 - __rust_maybe_catch_panic
35: 0x7f3f9708461a - _<F as alloc..boxed..FnBox<A>>::call_box::h3aad53cfb9d2713a
36: 0x7f3f96d5fc72 - std::sys::thread::Thread::new::thread_start::h4c0ad33b336bc6ea
37: 0x7f3f8fe6d453 - start_thread
38: 0x7f3f969a97de - __GI___clone
39: 0x0 - <unknown>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
[-]“Let qualified::NullaryConstructor = something;” causes internal compiler error: “tried to overwrite interned AdtDef”[/-][+]“Let NullaryConstructor = something;” causes internal compiler error: “tried to overwrite interned AdtDef”[/+]TimNN commentedon Oct 7, 2016
Works fine on 1.11.
TimNN commentedon Oct 7, 2016
Affects beta as well.
Requires the type on the lhs to come from an extern crate.
This is fixed on
nightly-2016-10-06(nightly-2016-10-04still fails, Changes)I suspect this was fixed by #36814 (although I may be wrong).
TimNN commentedon Oct 7, 2016
Originally introduced between
nightly-2016-07-09andnightly-2016-07-10(Changes)The most likely cause is #34365, I think.
jseyfried commentedon Oct 7, 2016
cc @petrochenkov
petrochenkov commentedon Oct 9, 2016
This happens when
decoder::get_adt_defgets struct constructorDefIdas an argument (as opposed toDefIdof the struct itself) + it's the first time this struct is decoded.#36814 doesn't fix this issue, only masks it, it still can be reproduced with tuple struct patterns.
How to fix this: add something like this at the beginning of
decoder::get_adt_def:I have no idea how
is_ctor_idandget_struct_idcan be implemented, need to investigate how new metadata works.petrochenkov commentedon Oct 10, 2016
Fix for beta is in #37078
nikomatsakis commentedon Oct 11, 2016
Nice job @petrochenkov
Auto merge of #37095 - petrochenkov:metactor, r=alexcrichton