ICE: shouldn't have created a ValTree for *const ..
#119270
Closed
Description
opened on Dec 24, 2023
auto-reduced (treereduce-rust):
struct NoDerive(i32);
#[derive(PartialEq)]
struct WrapEmbedded(*const NoDerive);
const WRAP_UNSAFE_EMBEDDED: &&WrapEmbedded = &&WrapEmbedded(std::ptr::null());
fn main() {
match WRAP_UNSAFE_EMBEDDED {
WRAP_UNSAFE_EMBEDDED => {}
_ => {}
}
}
original:
// Test explores how `#[structral_match]` behaves in tandem with
// `*const` and `*mut` pointers.
// run-pass
#![warn(pointer_structural_match)]
struct NoDerive(#[allow(unused_tuple_struct_fields)] i32);
// This impl makes NoDerive irreflexive
// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
impl Eq for NoDerive { }
#[derive(PartialEq)]
struct WrapEmbedded(*const NoDerive);
const WRAP_UNSAFE_EMBEDDED: & &WrapEmbedded = & &WrapEmbedded(std::ptr::null());
fn main() {
match WRAP_UNSAFE_EMBEDDED {
WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); }
_ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); }
}
}
Version information
rustc 1.77.0-nightly (2d7be7393 2023-12-23)
binary: rustc
commit-hash: 2d7be73931e0978c8758a672cc7258b417a7e999
commit-date: 2023-12-23
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: to use a constant of type `WrapEmbedded` in a pattern, `WrapEmbedded` must be annotated with `#[derive(PartialEq, Eq)]`
--> /tmp/icemaker_global_tempdir.9xUyew01Yauq/rustc_testrunner_tmpdir_reporting.KFwoDPkopCSi/mvce.rs:10:9
|
10 | WRAP_UNSAFE_EMBEDDED => {}
| ^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
= note: the traits must be derived, manual `impl`s are not sufficient
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
= note: `#[warn(indirect_structural_match)]` on by default
error: internal compiler error: compiler/rustc_const_eval/src/const_eval/valtrees.rs:404:14: shouldn't have created a ValTree for *const NoDerive
thread 'rustc' panicked at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/compiler/rustc_errors/src/lib.rs:1056:30:
Box<dyn Any>
stack backtrace:
0: 0x7fbbfb78b6f6 - std::backtrace_rs::backtrace::libunwind::trace::h854d9901466ba2a6
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7fbbfb78b6f6 - std::backtrace_rs::backtrace::trace_unsynchronized::h2e5473e1358f3d7d
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7fbbfb78b6f6 - std::sys_common::backtrace::_print_fmt::h17999543628ef5b9
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7fbbfb78b6f6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4a315f9d82cb167
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7fbbfb7ddf40 - core::fmt::rt::Argument::fmt::h61d1362a4781e5b2
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/core/src/fmt/rt.rs:142:9
5: 0x7fbbfb7ddf40 - core::fmt::write::hdd3124965f70515e
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/core/src/fmt/mod.rs:1120:17
6: 0x7fbbfb77f53f - std::io::Write::write_fmt::hf681a4235a84103e
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/io/mod.rs:1810:15
7: 0x7fbbfb78b4d4 - std::sys_common::backtrace::_print::hf875b2182006ee31
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7fbbfb78b4d4 - std::sys_common::backtrace::print::h6091516d06acaa34
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7fbbfb78e267 - std::panicking::default_hook::{{closure}}::h7008dc256987fa65
10: 0x7fbbfb78dfc9 - std::panicking::default_hook::he81ec00845e2991e
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/panicking.rs:292:9
11: 0x7fbbfe55adec - std[76579cbcf5e75e71]::panicking::update_hook::<alloc[b53221f29dc7d1be]::boxed::Box<rustc_driver_impl[5725e9f2ae9a40a2]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7fbbfb78e9b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hfccb34defa5e1891
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/alloc/src/boxed.rs:2029:9
13: 0x7fbbfb78e9b6 - std::panicking::rust_panic_with_hook::ha947ff64165fedb2
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/panicking.rs:783:13
14: 0x7fbbfe593a94 - std[76579cbcf5e75e71]::panicking::begin_panic::<rustc_errors[64d26b4b709225b4]::ExplicitBug>::{closure#0}
15: 0x7fbbfe5901d6 - std[76579cbcf5e75e71]::sys_common::backtrace::__rust_end_short_backtrace::<std[76579cbcf5e75e71]::panicking::begin_panic<rustc_errors[64d26b4b709225b4]::ExplicitBug>::{closure#0}, !>
16: 0x7fbbfe58fb86 - std[76579cbcf5e75e71]::panicking::begin_panic::<rustc_errors[64d26b4b709225b4]::ExplicitBug>
17: 0x7fbbfe59e991 - <rustc_errors[64d26b4b709225b4]::diagnostic_builder::BugAbort as rustc_errors[64d26b4b709225b4]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
18: 0x7fbbfe97152e - <rustc_errors[64d26b4b709225b4]::DiagCtxt>::bug::<alloc[b53221f29dc7d1be]::string::String>
19: 0x7fbbfea0ca7b - rustc_middle[3892716d31dc4121]::util::bug::opt_span_bug_fmt::<rustc_span[d159d62802098cb3]::span_encoding::Span>::{closure#0}
20: 0x7fbbfe9f5e1a - rustc_middle[3892716d31dc4121]::ty::context::tls::with_opt::<rustc_middle[3892716d31dc4121]::util::bug::opt_span_bug_fmt<rustc_span[d159d62802098cb3]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21: 0x7fbbfe9f5cb8 - rustc_middle[3892716d31dc4121]::ty::context::tls::with_context_opt::<rustc_middle[3892716d31dc4121]::ty::context::tls::with_opt<rustc_middle[3892716d31dc4121]::util::bug::opt_span_bug_fmt<rustc_span[d159d62802098cb3]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22: 0x7fbbfc9a05a0 - rustc_middle[3892716d31dc4121]::util::bug::bug_fmt
23: 0x7fbc001aa610 - rustc_const_eval[ea3edab3442d2e4]::const_eval::valtrees::valtree_into_mplace
24: 0x7fbc001aa26c - rustc_const_eval[ea3edab3442d2e4]::const_eval::valtrees::valtree_into_mplace
25: 0x7fbc001a9181 - rustc_const_eval[ea3edab3442d2e4]::const_eval::valtrees::valtree_to_ref
26: 0x7fbc001aa4d0 - rustc_const_eval[ea3edab3442d2e4]::const_eval::valtrees::valtree_into_mplace
27: 0x7fbc001a9181 - rustc_const_eval[ea3edab3442d2e4]::const_eval::valtrees::valtree_to_ref
28: 0x7fbc000cd64e - rustc_const_eval[ea3edab3442d2e4]::const_eval::valtrees::valtree_to_const_value
29: 0x7fbc000cd461 - <rustc_const_eval[ea3edab3442d2e4]::provide::{closure#1} as core[730ecc411c8eaf02]::ops::function::FnOnce<(rustc_middle[3892716d31dc4121]::ty::context::TyCtxt, (rustc_middle[3892716d31dc4121]::ty::Ty, rustc_middle[3892716d31dc4121]::ty::consts::valtree::ValTree))>>::call_once
30: 0x7fbc000cd42e - rustc_query_impl[d4cc752ff0d73f28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d4cc752ff0d73f28]::query_impl::valtree_to_const_val::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3892716d31dc4121]::query::erase::Erased<[u8; 24usize]>>
31: 0x7fbc000cd3f7 - <rustc_query_impl[d4cc752ff0d73f28]::query_impl::valtree_to_const_val::dynamic_query::{closure#2} as core[730ecc411c8eaf02]::ops::function::FnOnce<(rustc_middle[3892716d31dc4121]::ty::context::TyCtxt, (rustc_middle[3892716d31dc4121]::ty::Ty, rustc_middle[3892716d31dc4121]::ty::consts::valtree::ValTree))>>::call_once
32: 0x7fbc000ccc92 - rustc_query_system[d117b86e449fcdf2]::query::plumbing::try_execute_query::<rustc_query_impl[d4cc752ff0d73f28]::DynamicConfig<rustc_query_system[d117b86e449fcdf2]::query::caches::DefaultCache<(rustc_middle[3892716d31dc4121]::ty::Ty, rustc_middle[3892716d31dc4121]::ty::consts::valtree::ValTree), rustc_middle[3892716d31dc4121]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[d4cc752ff0d73f28]::plumbing::QueryCtxt, false>
33: 0x7fbc000cc9e4 - rustc_query_impl[d4cc752ff0d73f28]::query_impl::valtree_to_const_val::get_query_non_incr::__rust_end_short_backtrace
34: 0x7fbbfd36ccc5 - <rustc_mir_transform[9620eec9afded333]::const_prop_lint::ConstPropagator as rustc_middle[3892716d31dc4121]::mir::visit::Visitor>::visit_operand
35: 0x7fbbfd366c9e - <rustc_mir_transform[9620eec9afded333]::const_prop_lint::ConstPropagator as rustc_middle[3892716d31dc4121]::mir::visit::Visitor>::visit_basic_block_data
36: 0x7fbbff9ffed2 - <rustc_mir_transform[9620eec9afded333]::const_prop_lint::ConstPropLint as rustc_mir_transform[9620eec9afded333]::pass_manager::MirLint>::run_lint
37: 0x7fbbff862897 - rustc_mir_transform[9620eec9afded333]::run_analysis_to_runtime_passes
38: 0x7fbbfd0469ff - rustc_mir_transform[9620eec9afded333]::mir_drops_elaborated_and_const_checked
39: 0x7fbbff9ed635 - rustc_query_impl[d4cc752ff0d73f28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d4cc752ff0d73f28]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3892716d31dc4121]::query::erase::Erased<[u8; 8usize]>>
40: 0x7fbbff9ed8c3 - rustc_query_system[d117b86e449fcdf2]::query::plumbing::try_execute_query::<rustc_query_impl[d4cc752ff0d73f28]::DynamicConfig<rustc_query_system[d117b86e449fcdf2]::query::caches::VecCache<rustc_span[d159d62802098cb3]::def_id::LocalDefId, rustc_middle[3892716d31dc4121]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d4cc752ff0d73f28]::plumbing::QueryCtxt, false>
41: 0x7fbbff9ed190 - rustc_query_impl[d4cc752ff0d73f28]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
42: 0x7fbbfffed7aa - rustc_interface[1da9c7dc31a5385c]::passes::analysis
43: 0x7fbbfffecf9d - rustc_query_impl[d4cc752ff0d73f28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d4cc752ff0d73f28]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3892716d31dc4121]::query::erase::Erased<[u8; 1usize]>>
44: 0x7fbc0070f940 - rustc_query_system[d117b86e449fcdf2]::query::plumbing::try_execute_query::<rustc_query_impl[d4cc752ff0d73f28]::DynamicConfig<rustc_query_system[d117b86e449fcdf2]::query::caches::SingleCache<rustc_middle[3892716d31dc4121]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d4cc752ff0d73f28]::plumbing::QueryCtxt, false>
45: 0x7fbc0070f747 - rustc_query_impl[d4cc752ff0d73f28]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
46: 0x7fbc007a8b12 - rustc_interface[1da9c7dc31a5385c]::interface::run_compiler::<core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>, rustc_driver_impl[5725e9f2ae9a40a2]::run_compiler::{closure#0}>::{closure#0}
47: 0x7fbc0072b486 - std[76579cbcf5e75e71]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1da9c7dc31a5385c]::util::run_in_thread_with_globals<rustc_interface[1da9c7dc31a5385c]::util::run_in_thread_pool_with_globals<rustc_interface[1da9c7dc31a5385c]::interface::run_compiler<core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>, rustc_driver_impl[5725e9f2ae9a40a2]::run_compiler::{closure#0}>::{closure#0}, core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>>::{closure#0}, core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>>
48: 0x7fbc0072b2b3 - <<std[76579cbcf5e75e71]::thread::Builder>::spawn_unchecked_<rustc_interface[1da9c7dc31a5385c]::util::run_in_thread_with_globals<rustc_interface[1da9c7dc31a5385c]::util::run_in_thread_pool_with_globals<rustc_interface[1da9c7dc31a5385c]::interface::run_compiler<core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>, rustc_driver_impl[5725e9f2ae9a40a2]::run_compiler::{closure#0}>::{closure#0}, core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>>::{closure#0}, core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[730ecc411c8eaf02]::result::Result<(), rustc_span[d159d62802098cb3]::ErrorGuaranteed>>::{closure#1} as core[730ecc411c8eaf02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
49: 0x7fbbfb7988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hca712a7e6055e033
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/alloc/src/boxed.rs:2015:9
50: 0x7fbbfb7988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0c4d9df2b2c66b37
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/alloc/src/boxed.rs:2015:9
51: 0x7fbbfb7988e5 - std::sys::unix::thread::Thread::new::thread_start::h42e6b966712cbe95
at /rustc/2d7be73931e0978c8758a672cc7258b417a7e999/library/std/src/sys/unix/thread.rs:108:17
52: 0x7fbbfb5849eb - <unknown>
53: 0x7fbbfb6087cc - <unknown>
54: 0x0 - <unknown>
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.77.0-nightly (2d7be7393 2023-12-23) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to mir constant value
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted
Activity