Closed
Description
I tried this code (reduced from a macro expansion in previously working code):
fn main() {
if let Some(val) = None as Option<String> {
println!("never reached for val={}", val);
}
println!("end of test");
}
I expected to see this happen:
Prior to a recent change, this compiles and running the program prints "end of test".
Instead, this happened:
rustc -Copt-level=s broken_mir.rs
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ broken_mir[b66b]::main), const_param_did: None }) (end of phase Optimization) at bb5[0]:
use of local _2, which has no storage here
--> broken_mir.rs:4:5
|
4 | }
| ^
|
Meta
rustc --version --verbose
:
rustc 1.56.0-nightly (2a6fb9a4c 2021-08-16)
binary: rustc
commit-hash: 2a6fb9a4c0e5ca7a81999065943b211c226fe9d8
commit-date: 2021-08-16
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
Note, I also tested with a version of the compiler just prior to the commit-hash above, and the program compiles and runs correctly under -C opt-level=s
:
rustc 1.56.0-nightly (2bd17c1d4 2021-08-15)
binary: rustc
commit-hash: 2bd17c1d43bba43412cc2f051323a279d6751e43
commit-date: 2021-08-15
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
So this appears to confirm the error was introduced with the PR Introduce hir::ExprKind::Let - Take 2 #80357
Backtrace
= note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1134:13
stack backtrace:
0: 0x7fe0c362f140 - std::backtrace_rs::backtrace::libunwind::trace::hea80398fdae6c868
at /usr/local/google/home/richkadel/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
1: 0x7fe0c362f140 - std::backtrace_rs::backtrace::trace_unsynchronized::h9f50f49ec5fa6e70
at /usr/local/google/home/richkadel/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7fe0c362f140 - std::sys_common::backtrace::_print_fmt::hae6bb9b578c9b29f
at /usr/local/google/home/richkadel/rust/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7fe0c362f140 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4976016e0890e206
at /usr/local/google/home/richkadel/rust/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7fe0c36a840a - core::fmt::write::hb4b241262ffb1648
at /usr/local/google/home/richkadel/rust/library/core/src/fmt/mod.rs:1117:17
5: 0x7fe0c361eef5 - std::io::Write::write_fmt::h44e5eb8ff82a1e4a
at /usr/local/google/home/richkadel/rust/library/std/src/io/mod.rs:1667:15
6: 0x7fe0c3632dc7 - std::sys_common::backtrace::_print::hf6914f4f16c92c55
at /usr/local/google/home/richkadel/rust/library/std/src/sys_common/backtrace.rs:49:5
7: 0x7fe0c3632dc7 - std::sys_common::backtrace::print::hcc87da1739c3aaca
at /usr/local/google/home/richkadel/rust/library/std/src/sys_common/backtrace.rs:36:9
8: 0x7fe0c3632dc7 - std::panicking::default_hook::{{closure}}::he49b902836396e57
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:210:50
9: 0x7fe0c363285b - std::panicking::default_hook::hae5ed4329a98ede1
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:227:9
10: 0x7fe0c4bbeac1 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h63fb9126cc2ce127
at /usr/local/google/home/richkadel/rust/library/alloc/src/boxed.rs:1650:9
11: 0x7fe0c4bbeac1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h9396e385a56f4bed
at /usr/local/google/home/richkadel/rust/compiler/rustc_driver/src/lib.rs:1168:13
12: 0x7fe0c363372b - std::panicking::rust_panic_with_hook::hf07e7a68ff83114b
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:628:17
13: 0x7fe0c36332b0 - std::panicking::begin_panic_handler::{{closure}}::hf8e7f92619198c2b
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:521:13
14: 0x7fe0c362f664 - std::sys_common::backtrace::__rust_end_short_backtrace::h4cd128bb5d2e259a
at /usr/local/google/home/richkadel/rust/library/std/src/sys_common/backtrace.rs:141:18
15: 0x7fe0c3633219 - rust_begin_unwind
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:517:5
16: 0x7fe0c36331cb - std::panicking::begin_panic_fmt::h9ad69cd7d22cbb05
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:460:5
17: 0x7fe0c7cc3da7 - rustc_errors::HandlerInner::flush_delayed::he9f0b08e429b4120
at /usr/local/google/home/richkadel/rust/compiler/rustc_errors/src/lib.rs:1134:13
18: 0x7fe0c7cc0056 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::he27b7550640b91da
at /usr/local/google/home/richkadel/rust/compiler/rustc_errors/src/lib.rs:457:13
19: 0x7fe0c4ba08b6 - core::ptr::drop_in_place<rustc_errors::HandlerInner>::h1fddd6a10951ea39
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
20: 0x7fe0c4ba08b6 - core::ptr::drop_in_place<core::cell::UnsafeCell<rustc_errors::HandlerInner>>::h8089e4af87ba1561
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
21: 0x7fe0c4ba08b6 - core::ptr::drop_in_place<core::cell::RefCell<rustc_errors::HandlerInner>>::h959277301dfb91dd
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
22: 0x7fe0c4ba08b6 - core::ptr::drop_in_place<rustc_data_structures::sync::Lock<rustc_errors::HandlerInner>>::h4cf921d64fa7e127
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
23: 0x7fe0c4ba08b6 - core::ptr::drop_in_place<rustc_errors::Handler>::hb0abdabff159574f
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
24: 0x7fe0c4ba08b6 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::h250de9d6f08eddd1
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
25: 0x7fe0c4badb0a - core::ptr::drop_in_place<rustc_session::session::Session>::h15edd041ec15c7aa
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
26: 0x7fe0c4badb0a - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hac422ce34a73cf8b
at /usr/local/google/home/richkadel/rust/library/alloc/src/rc.rs:1447:17
27: 0x7fe0c4bd391c - core::ptr::drop_in_place<alloc::rc::Rc<rustc_session::session::Session>>::h333742e4c00bd2a4
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
28: 0x7fe0c4bd391c - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::ha295b459177efaef
at /usr/local/google/home/richkadel/rust/library/core/src/ptr/mod.rs:192:1
29: 0x7fe0c4bd0161 - core::mem::drop::h66d5d49438019dda
at /usr/local/google/home/richkadel/rust/library/core/src/mem/mod.rs:898:24
30: 0x7fe0c4bd0161 - rustc_interface::interface::create_compiler_and_run::{{closure}}::{{closure}}::hb35f7751fe9465ba
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/interface.rs:213:60
31: 0x7fe0c4bd0161 - rustc_data_structures::profiling::TimingGuard::run::he109aac39e941265
at /usr/local/google/home/richkadel/rust/compiler/rustc_data_structures/src/profiling.rs:590:9
32: 0x7fe0c4bd0161 - rustc_interface::interface::create_compiler_and_run::{{closure}}::h758b9b7a8ec1284d
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/interface.rs:213:9
33: 0x7fe0c4bd0161 - rustc_span::with_source_map::hda971ba47a0aae9d
at /usr/local/google/home/richkadel/rust/compiler/rustc_span/src/lib.rs:911:5
34: 0x7fe0c4c2829d - rustc_interface::interface::create_compiler_and_run::ha68ef7270ae1e9cb
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/interface.rs:203:5
35: 0x7fe0c4c1b514 - rustc_interface::interface::run_compiler::{{closure}}::h7cb658bac73132a1
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/interface.rs:225:12
36: 0x7fe0c4c1b514 - rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}::he2c991290c9086da
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/util.rs:157:13
37: 0x7fe0c4c1b514 - scoped_tls::ScopedKey<T>::set::haeb10a9e94d49d73
at /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
38: 0x7fe0c4bd0a9b - rustc_span::create_session_globals_then::h662e3754c17324ec
at /usr/local/google/home/richkadel/rust/compiler/rustc_span/src/lib.rs:105:5
39: 0x7fe0c4bd0a9b - rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::h1a7bf06b03cda53c
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/util.rs:155:9
40: 0x7fe0c4bd0a9b - rustc_interface::util::scoped_thread::{{closure}}::hd3ccbf65bc3be109
at /usr/local/google/home/richkadel/rust/compiler/rustc_interface/src/util.rs:130:24
41: 0x7fe0c4bd0a9b - std::sys_common::backtrace::__rust_begin_short_backtrace::h1e0b27d30679266c
at /usr/local/google/home/richkadel/rust/library/std/src/sys_common/backtrace.rs:125:18
42: 0x7fe0c4bc3153 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hbb1d7f396bfa357d
at /usr/local/google/home/richkadel/rust/library/std/src/thread/mod.rs:481:17
43: 0x7fe0c4bc3153 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h5f8fe49cb0f0f6ef
at /usr/local/google/home/richkadel/rust/library/core/src/panic/unwind_safe.rs:271:9
44: 0x7fe0c4bc3153 - std::panicking::try::do_call::h60b73e9676461207
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:403:40
45: 0x7fe0c4bc3153 - std::panicking::try::h1780424951bc2eb7
at /usr/local/google/home/richkadel/rust/library/std/src/panicking.rs:367:19
46: 0x7fe0c4bc3153 - std::panic::catch_unwind::h12ff5482189241be
at /usr/local/google/home/richkadel/rust/library/std/src/panic.rs:129:14
47: 0x7fe0c4bc3153 - std::thread::Builder::spawn_unchecked::{{closure}}::h8c61c171cefb6690
at /usr/local/google/home/richkadel/rust/library/std/src/thread/mod.rs:480:30
48: 0x7fe0c4bc3153 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h100cbb8448bf0f09
at /usr/local/google/home/richkadel/rust/library/core/src/ops/function.rs:227:5
49: 0x7fe0c3640c03 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h111b7c61a75bd788
at /usr/local/google/home/richkadel/rust/library/alloc/src/boxed.rs:1636:9
50: 0x7fe0c3640c03 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha3e1896aed4c42e9
at /usr/local/google/home/richkadel/rust/library/alloc/src/boxed.rs:1636:9
51: 0x7fe0c3640c03 - std::sys::unix::thread::Thread::new::thread_start::ha0bb87288a6a01a3
at /usr/local/google/home/richkadel/rust/library/std/src/sys/unix/thread.rs:106:17
52: 0x7fe0bf85aea7 - start_thread
53: 0x7fe0c3437def - clone
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.56.0-nightly (2a6fb9a4c 2021-08-16) running on x86_64-unknown-linux-gnu
note: compiler flags: -C opt-level=s
query stack during panic:
end of query stack