Skip to content

rustc internal compiler error: bad placeholder type #68162

Closed
@heilhead

Description

@heilhead

The following code causes a compiler crash:

extern crate spin;

fn main() {
    static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
    SINGLETON_STATIC.call_once(|| 0u32);
}

Replacing spin::Once<_> with spin::Once<u32> works properly.

Rust version:

rustc 1.42.0-nightly (859764425 2020-01-07)
binary: rustc
commit-hash: 85976442558bf2d09cec3aa49c9c9ba86fb15c1f
commit-date: 2020-01-07
host: x86_64-pc-windows-msvc
release: 1.42.0-nightly
LLVM version: 9.0

Full output:

C:\git\rust-macro-crash>cargo build
   Compiling rust-macro-crash v0.1.0 (C:\git\rust-macro-crash)
warning: unused variable: `bar1`
 --> src\main.rs:8:9
  |
8 |     let bar1: &u32 = {
  |         ^^^^ help: consider prefixing with an underscore: `_bar1`
  |
  = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/85976442558bf2d09cec3aa49c9c9ba86fb15c1f\src\libcore\slice\mod.rs:2791:10
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSlice as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook                                                                                                                                                      
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic_bounds_check
  10: <rustc_mir::borrow_check::type_check::relate_tys::NllTypeRelatingDelegate as rustc::infer::nll_relate::TypeRelatingDelegate>::push_domain_goal
  11: <rustc_mir::borrow_check::invalidation::InvalidationGenerator as rustc::mir::visit::Visitor>::visit_terminator_kind
  12: <rustc_mir::hair::pattern::PatRange as core::fmt::Debug>::fmt
  13: <rustc_mir::borrow_check::region_infer::RegionRelationCheckResult as core::fmt::Debug>::fmt
  14: <rustc_mir::hair::pattern::PatRange as core::fmt::Debug>::fmt
  15: <rustc_interface::util::ReplaceBodyWithLoop as syntax::mut_visit::MutVisitor>::visit_mac
  16: <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  17: <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  18: <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  19: <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  20: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::compile
  21: rustc_interface::passes::QueryContext::print_stats
  22: <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt
  23: rustc_driver::pretty::print_after_hir_lowering
  24: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  25: rustc_driver::pretty::print_after_hir_lowering
  26: rustc_driver::pretty::print_after_hir_lowering
  27: <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt
  28: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  29: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  30: _rust_maybe_catch_panic
  31: rustc_driver::pretty::print_after_hir_lowering
  32: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Send$u2b$core..marker..Sync$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  33: std::sys::windows::thread::Thread::new
  34: BaseThreadInitThunk                                                                                                                                                            
  35: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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: rustc 1.42.0-nightly (859764425 2020-01-07) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] processing `main::{{closure}}#0`
#1 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: bad placeholder type
 --> src\main.rs:9:45
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |                                             ^

error: internal compiler error: cat_expr Errd
 --> src\main.rs:9:50
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |                                                  ^^^^^^^^^^^^^^^^^

error: internal compiler error: cat_expr Errd
 --> src\main.rs:9:50
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |                                                  ^^^^^^^^^^^^^^^

error: internal compiler error: cat_expr Errd
  --> src\main.rs:7:11
   |
7  |   fn main() {
   |  ___________^
8  | |     let bar1: &u32 = {
9  | |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
10 | |         SINGLETON_STATIC.call_once(|| test())
11 | |     };
12 | | }
   | |_^

error: internal compiler error: cat_expr Errd
  --> src\main.rs:8:22
   |
8  |       let bar1: &u32 = {
   |  ______________________^
9  | |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
10 | |         SINGLETON_STATIC.call_once(|| test())
11 | |     };
   | |_____^

error: internal compiler error: cat_expr Errd
  --> src\main.rs:10:9
   |
10 |         SINGLETON_STATIC.call_once(|| test())
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: cat_expr Errd
  --> src\main.rs:10:9
   |
10 |         SINGLETON_STATIC.call_once(|| test())
   |         ^^^^^^^^^^^^^^^^

error: internal compiler error: cat_expr Errd
  --> src\main.rs:10:36
   |
10 |         SINGLETON_STATIC.call_once(|| test())
   |                                    ^^^^^^^^^

error: internal compiler error: PromoteTemps: MIR had errors
  --> src\main.rs:7:1
   |
7  | / fn main() {
8  | |     let bar1: &u32 = {
9  | |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
10 | |         SINGLETON_STATIC.call_once(|| test())
11 | |     };
12 | | }
   | |_^

error: internal compiler error: broken MIR in DefId(0:5 ~ rust_macro_crash[4413]::main[0]) ("return type"): bad type [type error]
  --> src\main.rs:7:1
   |
7  | / fn main() {
8  | |     let bar1: &u32 = {
9  | |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
10 | |         SINGLETON_STATIC.call_once(|| test())
11 | |     };
12 | | }
   | |_^

error: internal compiler error: broken MIR in DefId(0:5 ~ rust_macro_crash[4413]::main[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src\main.rs:7:1: 12:2, scope: scope[0] } }): bad type [type error]
  --> src\main.rs:7:1
   |
7  | / fn main() {
8  | |     let bar1: &u32 = {
9  | |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
10 | |         SINGLETON_STATIC.call_once(|| test())
11 | |     };
12 | | }
   | |_^

error: internal compiler error: mir_const_qualif: MIR had errors
 --> src\main.rs:9:9
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: PromoteTemps: MIR had errors
 --> src\main.rs:9:9
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: broken MIR in DefId(0:6 ~ rust_macro_crash[4413]::main[0]::SINGLETON_STATIC[0]) ("return type"): bad type [type error]
 --> src\main.rs:9:9
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: broken MIR in DefId(0:6 ~ rust_macro_crash[4413]::main[0]::SINGLETON_STATIC[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src\main.rs:9:9: 9:68, scope: scope[0] } }): bad type [type error] --> src\main.rs:9:9
  |
9 |         static SINGLETON_STATIC: spin::Once<_> = spin::Once::new();
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: PromoteTemps: MIR had errors
  --> src\main.rs:10:36
   |
10 |         SINGLETON_STATIC.call_once(|| test())
   |                                    ^^^^^^^^^

error: internal compiler error: broken MIR in DefId(0:7 ~ rust_macro_crash[4413]::main[0]::{{closure}}[0]) ("return type"): bad type [type error]
  --> src\main.rs:10:36
   |
10 |         SINGLETON_STATIC.call_once(|| test())
   |                                    ^^^^^^^^^

error: internal compiler error: broken MIR in DefId(0:7 ~ rust_macro_crash[4413]::main[0]::{{closure}}[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src\main.rs:10:36: 10:45, scope: scope[0] } }): bad type [type error]  
  --> src\main.rs:10:36
   |
10 |         SINGLETON_STATIC.call_once(|| test())
   |                                    ^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src\librustc_errors\lib.rs:347:17
stack backtrace:
   0:     0x7ff9d2b97449 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1095fd65914af34d
   1:     0x7ff9d2bc1cdb - core::fmt::write::hdc7c54b3d580259b
   2:     0x7ff9d2b89174 - <std::io::IoSlice as core::fmt::Debug>::fmt::h8b3edc617bb370a8
   3:     0x7ff9d2b9ba29 - std::panicking::take_hook::h9fa2030209e90419
   4:     0x7ff9d2b9b67c - std::panicking::take_hook::h9fa2030209e90419
   5:     0x7ff995034d54 - rustc_driver::report_ice::hfd255ef72e41bb17
   6:     0x7ff9d2b9c1fc - std::panicking::rust_panic_with_hook::hfa2b7b16fa988648
   7:     0x7ff998983a7d - rustc_errors::diagnostic_builder::DiagnosticBuilder::code::hd1da51d03c05e5b2
   8:     0x7ff99897de7d - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::hb582a2593a041559
   9:     0x7ff995008a77 - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  10:     0x7ff994fef356 - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  11:     0x7ff994fefa3c - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  12:     0x7ff994feab2f - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  13:     0x7ff998adc2b0 - _rust_realloc
  14:     0x7ff998adbb0b - _rust_realloc
  15:     0x7ff998ad9834 - _rust_realloc
  16:     0x7ff998adb64e - _rust_realloc
  17:     0x7ff998ad9ce5 - _rust_realloc
  18:     0x7ffa02c7018f - _chkstk
  19:     0x7ffa02bf1c56 - RtlUnwindEx
  20:     0x7ff9d2be1da5 - <libc::windows::timeval as core::clone::Clone>::clone::hdd1a8d652a4825ad
  21:     0x7ff9d2be2bcc - <libc::windows::timeval as core::clone::Clone>::clone::hdd1a8d652a4825ad
  22:     0x7ff9d2be2ec3 - <libc::windows::timeval as core::clone::Clone>::clone::hdd1a8d652a4825ad
  23:     0x7ff9d2be35e0 - <libc::windows::timeval as core::clone::Clone>::clone::hdd1a8d652a4825ad
  24:     0x7ff9d2be1f15 - <libc::windows::timeval as core::clone::Clone>::clone::hdd1a8d652a4825ad
  25:     0x7ffa02c7010f - _chkstk
  26:     0x7ffa02c1b4e4 - RtlRaiseException
  27:     0x7ffa02c1b235 - RtlRaiseException
  28:     0x7ffa00473e49 - RaiseException
  29:     0x7ff9d2be227d - <libc::windows::timeval as core::clone::Clone>::clone::hdd1a8d652a4825ad
  30:     0x7ff9d2badb03 - _rust_start_panic
  31:     0x7ff9d2badaa9 - _rust_start_panic
  32:     0x7ff9d2b9c3a8 - rust_panic
  33:     0x7ff9d2b9c289 - std::panicking::rust_panic_with_hook::hfa2b7b16fa988648
  34:     0x7ff9d2b9bd85 - rust_begin_unwind
  35:     0x7ff9d2bbe72d - core::panicking::panic_fmt::he62b30d85e14e28b
  36:     0x7ff9d2bbe6fa - core::panicking::panic_bounds_check::haf6d164417db1d4f
  37:     0x7ff997900455 - <rustc_mir::borrow_check::type_check::relate_tys::NllTypeRelatingDelegate as rustc::infer::nll_relate::TypeRelatingDelegate>::push_domain_goal::hc44aec63dda54d8f
  38:     0x7ff99786b49b - <rustc_mir::borrow_check::invalidation::InvalidationGenerator as rustc::mir::visit::Visitor>::visit_terminator_kind::h46a43fcdd4c80d94
  39:     0x7ff9979cc73d - <rustc_mir::hair::pattern::PatRange as core::fmt::Debug>::fmt::h30d0464933b99dc9
  40:     0x7ff9976901a6 - <rustc_mir::borrow_check::region_infer::RegionRelationCheckResult as core::fmt::Debug>::fmt::haf3327dcc27fe819
  41:     0x7ff9979cbaf0 - <rustc_mir::hair::pattern::PatRange as core::fmt::Debug>::fmt::h30d0464933b99dc9
  42:     0x7ff9951301a5 - <rustc_interface::util::ReplaceBodyWithLoop as syntax::mut_visit::MutVisitor>::visit_mac::h047bd519f96a8ef1
  43:     0x7ff9951c1fe1 - <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h043738651f239b7d
  44:     0x7ff99520739a - <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h043738651f239b7d
  45:     0x7ff9951d88af - <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h043738651f239b7d
  46:     0x7ff9951c1d5a - <rustc_interface::proc_macro_decls::Finder as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h043738651f239b7d
  47:     0x7ff9951931d4 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::compile::hb9e9d8f7f406580e
  48:     0x7ff99513c713 - rustc_interface::passes::QueryContext::print_stats::h783268cfacc38309
  49:     0x7ff994fc0833 - <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt::h9f9d88cdcd88c47f
  50:     0x7ff99501429d - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  51:     0x7ff99503ced7 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::hf4d2a3fdc72fd02c
  52:     0x7ff99501141d - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  53:     0x7ff994fe9daf - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  54:     0x7ff994fc48ce - <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt::h9f9d88cdcd88c47f
  55:     0x7ff995041819 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::hf4d2a3fdc72fd02c
  56:     0x7ff994fbe0ac - <env_logger::filter::inner::Filter as core::fmt::Display>::fmt::hab669cf4fa09e2c5
  57:     0x7ff9d2bada32 - _rust_maybe_catch_panic
  58:     0x7ff994fcdf22 - rustc_driver::pretty::print_after_hir_lowering::h3ec854b3772266dc
  59:     0x7ff9d2b779c7 - ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Send$u2b$core..marker..Sync$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  60:     0x7ff9d2bab2f7 - std::sys::windows::thread::Thread::new::h9e5104b131d416be
  61:     0x7ffa014a6fd4 - BaseThreadInitThunk
  62:     0x7ffa02c1cf31 - RtlUserThreadStart

error: internal compiler error: unexpected panic

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: rustc 1.42.0-nightly (859764425 2020-01-07) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `rust-macro-crash`.

Caused by:
  process didn't exit successfully: `rustc --crate-name rust_macro_crash --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=7766437149f6ecd8 --out-dir C:\git\rust-macro-crash\target\debug\deps -C incremental=C:\git\rust-macro-crash\target\debug\incremental -L dependency=C:\git\rust-macro-crash\target\debug\deps --extern spin=C:\git\rust-macro-crash\target\debug\deps\libspin-135b72c82d3f63ac.rlib` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions