Repository navigation
ice: !layout.abi.is_uninhabited() #120337
Copy link
Copy link
Closed
Labels
-Zvalidate-mirUnstable option: MIR validationUnstable option: MIR validationA-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-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-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Code
fn test_questionmark() -> Result<(), ()> {
{
Ok(Ok(())) }??;
Ok(())
}
fn main() {
test_questionmark().unwrap();
}Meta
rustc --version --verbose:
rustc 1.77.0-nightly (039d88792 2024-01-25)
binary: rustc
commit-hash: 039d887928361df98ca530471b609378be93983a
commit-date: 2024-01-25
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
Error output
rustc --edition=2021 -Zvalidate-mir -Zmir-opt-level=5 -Zunsound-mir-opts treereduce.out
<output>
Backtrace
thread 'rustc' panicked at /rustc/039d887928361df98ca530471b609378be93983a/compiler/rustc_const_eval/src/interpret/projection.rs:222:9:
assertion failed: !layout.abi.is_uninhabited()
stack backtrace:
0: 0x7f5446c60e86 - std::backtrace_rs::backtrace::libunwind::trace::h6cfe1dadce630036
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7f5446c60e86 - std::backtrace_rs::backtrace::trace_unsynchronized::h5abdc3a3af169812
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f5446c60e86 - std::sys_common::backtrace::_print_fmt::hcccf5f4ed8ac28ec
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f5446c60e86 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0cd6b2504011a18d
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f5446cb3740 - core::fmt::rt::Argument::fmt::hebc7f15d5b5e154a
at /rustc/039d887928361df98ca530471b609378be93983a/library/core/src/fmt/rt.rs:142:9
5: 0x7f5446cb3740 - core::fmt::write::h78ef4d880a3b55e6
at /rustc/039d887928361df98ca530471b609378be93983a/library/core/src/fmt/mod.rs:1120:17
6: 0x7f5446c5484f - std::io::Write::write_fmt::h75a99451377d7b6f
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/io/mod.rs:1810:15
7: 0x7f5446c60c64 - std::sys_common::backtrace::_print::h8a38d616c1aebba6
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f5446c60c64 - std::sys_common::backtrace::print::h79c60f2fb75766d0
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f5446c639f7 - std::panicking::default_hook::{{closure}}::h813367f17128fa78
10: 0x7f5446c63759 - std::panicking::default_hook::h9a25a86054ecacab
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/panicking.rs:292:9
11: 0x7f544395b54c - std[2d71ddef07c6339c]::panicking::update_hook::<alloc[562726949fe228d0]::boxed::Box<rustc_driver_impl[b5150a49514b53ca]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f5446c64146 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcf7035261c2dc2f4
at /rustc/039d887928361df98ca530471b609378be93983a/library/alloc/src/boxed.rs:2030:9
13: 0x7f5446c64146 - std::panicking::rust_panic_with_hook::h4227801d760693f2
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/panicking.rs:785:13
14: 0x7f5446c63e59 - std::panicking::begin_panic_handler::{{closure}}::h27ae2df27d1bb7d2
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/panicking.rs:651:13
15: 0x7f5446c61386 - std::sys_common::backtrace::__rust_end_short_backtrace::h08fba0b4aacd23ed
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/sys_common/backtrace.rs:171:18
16: 0x7f5446c63be4 - rust_begin_unwind
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/panicking.rs:647:5
17: 0x7f5446cafe45 - core::panicking::panic_fmt::haba40cee92bb0ca8
at /rustc/039d887928361df98ca530471b609378be93983a/library/core/src/panicking.rs:72:14
18: 0x7f5446caff03 - core::panicking::panic::h7ad960fca41cf254
at /rustc/039d887928361df98ca530471b609378be93983a/library/core/src/panicking.rs:144:5
19: 0x7f54461d9dbc - <rustc_const_eval[ed1a705a637fd062]::interpret::eval_context::InterpCx<rustc_mir_transform[963d0b588447d95f]::dataflow_const_prop::DummyMachine>>::project_downcast::<rustc_const_eval[ed1a705a637fd062]::interpret::operand::OpTy>.cold.0
20: 0x7f5443f9d12f - <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#0}
21: 0x7f5443ee8acb - <rustc_mir_dataflow[c9588bf85862e893]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[ed1a705a637fd062]::interpret::operand::OpTy, <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#1}>
22: 0x7f5443ee8b06 - <rustc_mir_dataflow[c9588bf85862e893]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[ed1a705a637fd062]::interpret::operand::OpTy, <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#1}>
23: 0x7f5443ee8b06 - <rustc_mir_dataflow[c9588bf85862e893]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[ed1a705a637fd062]::interpret::operand::OpTy, <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_constant::{closure#1}>
24: 0x7f5443f9d732 - <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::process_operand
25: 0x7f5443f9ca01 - <rustc_mir_transform[963d0b588447d95f]::jump_threading::TOFinder>::find_opportunity
26: 0x7f5443f9b459 - <rustc_mir_transform[963d0b588447d95f]::jump_threading::JumpThreading as rustc_middle[4fa995cc45e7b4f0]::mir::MirPass>::run_pass
27: 0x7f5444cc0a6e - rustc_mir_transform[963d0b588447d95f]::pass_manager::run_passes_inner
28: 0x7f5444df8789 - rustc_mir_transform[963d0b588447d95f]::optimized_mir
29: 0x7f5444c5e975 - rustc_query_impl[9793c2de2b9a9b0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9793c2de2b9a9b0]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 8usize]>>
30: 0x7f5444c5ef61 - rustc_query_system[822af879e6e17ac5]::query::plumbing::try_execute_query::<rustc_query_impl[9793c2de2b9a9b0]::DynamicConfig<rustc_query_system[822af879e6e17ac5]::query::caches::DefIdCache<rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9793c2de2b9a9b0]::plumbing::QueryCtxt, false>
31: 0x7f5444c5e79e - rustc_query_impl[9793c2de2b9a9b0]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
32: 0x7f5444dca77c - rustc_middle[4fa995cc45e7b4f0]::query::plumbing::query_get_at::<rustc_query_system[822af879e6e17ac5]::query::caches::DefIdCache<rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 8usize]>>>
33: 0x7f5444dc9b34 - rustc_mir_transform[963d0b588447d95f]::cross_crate_inline::cross_crate_inlinable
34: 0x7f5444dc571b - rustc_query_impl[9793c2de2b9a9b0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9793c2de2b9a9b0]::query_impl::cross_crate_inlinable::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 1usize]>>
35: 0x7f5444dc59f4 - rustc_query_system[822af879e6e17ac5]::query::plumbing::try_execute_query::<rustc_query_impl[9793c2de2b9a9b0]::DynamicConfig<rustc_query_system[822af879e6e17ac5]::query::caches::DefIdCache<rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9793c2de2b9a9b0]::plumbing::QueryCtxt, false>
36: 0x7f5444dc544d - rustc_query_impl[9793c2de2b9a9b0]::query_impl::cross_crate_inlinable::get_query_non_incr::__rust_end_short_backtrace
37: 0x7f544556e2c3 - <rustc_mir_transform[963d0b588447d95f]::inline::Inliner>::try_inlining
38: 0x7f5445572c91 - <rustc_mir_transform[963d0b588447d95f]::inline::Inliner>::process_blocks
39: 0x7f5444dca38b - <rustc_mir_transform[963d0b588447d95f]::inline::Inline as rustc_middle[4fa995cc45e7b4f0]::mir::MirPass>::run_pass
40: 0x7f5444cc0a6e - rustc_mir_transform[963d0b588447d95f]::pass_manager::run_passes_inner
41: 0x7f5444df8789 - rustc_mir_transform[963d0b588447d95f]::optimized_mir
42: 0x7f5444c5e975 - rustc_query_impl[9793c2de2b9a9b0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9793c2de2b9a9b0]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 8usize]>>
43: 0x7f5444c5ef61 - rustc_query_system[822af879e6e17ac5]::query::plumbing::try_execute_query::<rustc_query_impl[9793c2de2b9a9b0]::DynamicConfig<rustc_query_system[822af879e6e17ac5]::query::caches::DefIdCache<rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9793c2de2b9a9b0]::plumbing::QueryCtxt, false>
44: 0x7f5444c5e79e - rustc_query_impl[9793c2de2b9a9b0]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
45: 0x7f5441be32fa - <rustc_middle[4fa995cc45e7b4f0]::ty::context::TyCtxt>::instance_mir
46: 0x7f544292a6c1 - rustc_monomorphize[48429395c8d43f8f]::collector::collect_items_rec::{closure#0}
47: 0x7f5445a98aa7 - rustc_monomorphize[48429395c8d43f8f]::collector::collect_items_rec
48: 0x7f5445a9457b - rustc_monomorphize[48429395c8d43f8f]::partitioning::collect_and_partition_mono_items
49: 0x7f5445a93bd6 - rustc_query_impl[9793c2de2b9a9b0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9793c2de2b9a9b0]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 24usize]>>
50: 0x7f5445a93ba5 - <rustc_query_impl[9793c2de2b9a9b0]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[240f245c4852827c]::ops::function::FnOnce<(rustc_middle[4fa995cc45e7b4f0]::ty::context::TyCtxt, ())>>::call_once
51: 0x7f5445a92f47 - rustc_query_system[822af879e6e17ac5]::query::plumbing::try_execute_query::<rustc_query_impl[9793c2de2b9a9b0]::DynamicConfig<rustc_query_system[822af879e6e17ac5]::query::caches::SingleCache<rustc_middle[4fa995cc45e7b4f0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[9793c2de2b9a9b0]::plumbing::QueryCtxt, false>
52: 0x7f5445a92c49 - rustc_query_impl[9793c2de2b9a9b0]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
53: 0x7f54456a12d6 - rustc_codegen_ssa[c09e93a0fed8f3a3]::base::codegen_crate::<rustc_codegen_llvm[f9a1bb7d58de6587]::LlvmCodegenBackend>
54: 0x7f54456a0f75 - <rustc_codegen_llvm[f9a1bb7d58de6587]::LlvmCodegenBackend as rustc_codegen_ssa[c09e93a0fed8f3a3]::traits::backend::CodegenBackend>::codegen_crate
55: 0x7f544569f370 - rustc_interface[1f676e8d56904132]::passes::start_codegen
56: 0x7f544569eab4 - <rustc_interface[1f676e8d56904132]::queries::Queries>::codegen_and_build_linker
57: 0x7f544598d74a - rustc_interface[1f676e8d56904132]::interface::run_compiler::<core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>, rustc_driver_impl[b5150a49514b53ca]::run_compiler::{closure#0}>::{closure#0}
58: 0x7f5445bddb06 - std[2d71ddef07c6339c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1f676e8d56904132]::util::run_in_thread_with_globals<rustc_interface[1f676e8d56904132]::util::run_in_thread_pool_with_globals<rustc_interface[1f676e8d56904132]::interface::run_compiler<core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>, rustc_driver_impl[b5150a49514b53ca]::run_compiler::{closure#0}>::{closure#0}, core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>>::{closure#0}, core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>>
59: 0x7f5445bdd933 - <<std[2d71ddef07c6339c]::thread::Builder>::spawn_unchecked_<rustc_interface[1f676e8d56904132]::util::run_in_thread_with_globals<rustc_interface[1f676e8d56904132]::util::run_in_thread_pool_with_globals<rustc_interface[1f676e8d56904132]::interface::run_compiler<core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>, rustc_driver_impl[b5150a49514b53ca]::run_compiler::{closure#0}>::{closure#0}, core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>>::{closure#0}, core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[240f245c4852827c]::result::Result<(), rustc_span[6ce47fc6caf6b4a2]::ErrorGuaranteed>>::{closure#1} as core[240f245c4852827c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
60: 0x7f5446c6d735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hce32de47adeb9ab6
at /rustc/039d887928361df98ca530471b609378be93983a/library/alloc/src/boxed.rs:2016:9
61: 0x7f5446c6d735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h22cf91fbafc72b5d
at /rustc/039d887928361df98ca530471b609378be93983a/library/alloc/src/boxed.rs:2016:9
62: 0x7f5446c6d735 - std::sys::pal::unix::thread::Thread::new::thread_start::h4f77d8ca10599a35
at /rustc/039d887928361df98ca530471b609378be93983a/library/std/src/sys/pal/unix/thread.rs:108:17
63: 0x7f5440aaa9eb - <unknown>
64: 0x7f5440b2e7cc - <unknown>
65: 0x0 - <unknown>
error: 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: please attach the file at `/tmp/im/rustc-ice-2024-01-25T11_27_00-1814810.txt` to your bug report
note: compiler flags: -Z validate-mir -Z mir-opt-level=5 -Z unsound-mir-opts
query stack during panic:
#0 [optimized_mir] optimizing MIR for `test_questionmark`
#1 [cross_crate_inlinable] whether the item should be made inlinable across crates
#2 [optimized_mir] optimizing MIR for `main`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
Metadata
Metadata
Assignees
Labels
-Zvalidate-mirUnstable option: MIR validationUnstable option: MIR validationA-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-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-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Activity
compiler-errors commentedon Jan 25, 2024
-Zunsound-mir-opts+-Zvalidate-mirseem like options that when paired together would cause issues... At first glance, I'm actually not sure why this is filed as a bug.saethlin commentedon Jan 25, 2024
I agree. Nobody should be testing
-Zunsound-mir-opts, I don't know why those passes are even in the codebase.But this is a bug. I've found this in real code with a much smaller set of flags:
And this bisects to #119627 Bisected by hand, there's no nightly with that PR yet. Don't know where Matthias got that toolchain.
compiler-errors commentedon Jan 25, 2024
Afaict @matthiaskrgr likes to do ICE testing against master 😺
djkoloski commentedon Jan 25, 2024
We just hit this on Fuchsia as well. I think we should revert the PR until we fix this issue and reland it.
matthiaskrgr commentedon Jan 25, 2024
Another one with
--crate-type lib --emit=mirmatthiaskrgr commentedon Jan 25, 2024
Also here's a list of files from the rustc repo that all seem to trigger the problem in one way or another
tmiasko commentedon Jan 25, 2024
Looks like there is one more issue in GVN (
rustc +039d887928361df98ca530471b609378be93983a c.rs -O --crate-type=lib):tmiasko commentedon Jan 25, 2024
There is no basis for the assumption that interpreter will never downcast to an uninhabited variant:
RalfJung commentedon Jan 25, 2024
@tmiasko nice example!
That assert was added as an experiment to see if we ever hit that codepath, and it seems like the answer is yes. It should thus be removed, with a suitable const-eval test case.
RalfJung commentedon Jan 26, 2024
I wonder if that code shouldn't have a
Discriminantread somewhere though... it is conceptually a match after all.Still, the assertion should go: #120367.
That adds @tmiasko's test, but not the others.
apiraino commentedon Jan 26, 2024
WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-medium
Auto merge of rust-lang#120367 - RalfJung:project_downcast_uninhabite…
Auto merge of #120367 - RalfJung:project_downcast_uninhabited, r=oli-obk