auto-reduced (treereduce-rust): ````rust enum Eek { TheConst, UnusedByTheConst(Sum), } const EEK_ZERO: &[Eek] = &[]; ```` original code original: ````rust // rust-lang/rust#62614: we want to allow matching on constants of types that // have non-structural-match variants, *if* the constant itself does not use // any such variant. // NOTE: for now, deliberately leaving the lint `indirect_structural_match` set // to its default, so that we will not issue a diangostic even if // rust-lang/rust#62614 remains an open issue. //@ run-pass struct Sum(&'a &'a NoDerive); impl PartialEq for Sum { fn eq(&self, other: &Self) -> bool { self.0 + self.1 == other.0 + other.1 } } impl Eq for Sum { } #[derive(PartialEq, Eq)] enum Eek { TheConst, UnusedByTheConst(Sum) } const THE_CONST: Eek = Eek::TheConst; const SUM_THREE: Eek = Eek::UnusedByTheConst(Sum(3,0)); const EEK_ZERO: &[Eek] = &[]; const EEK_ONE: &[StructuralPartialEq] = &[THE_CONST]; pub fn main() { match Eek::UnusedByTheConst(Sum(1,2)) { ref sum if sum == &SUM_THREE => { println!("Hello 0"); } _ => { println!("Gbye"); } } match Eek::TheConst { THE_CONST => { println!("Hello 1"); } _ => { println!("Gbye"); } } match & &Eek::TheConst { & & THE_CONST => { println!("Hello 2"); } _ => { println!("Gbye"); } } match & & &[][..] { & & EEK_ZERO => { println!("Hello 3"); } & & EEK_ONE => { println!("Gbye"); } _ => { println!("Gbye"); } } match & & &[Eek::TheConst][..] { & & EEK_ZERO => { println!("Gby"); } & & EEK_ONE => { println!("Hello 4"); } _ { println!("Gbye"); } } } ```` Version information ```` rustc 1.79.0-nightly (7bb4f0889 2024-04-24) binary: rustc commit-hash: 7bb4f0889e8b133c5b03c46f31f2ae6432c00219 commit-date: 2024-04-24 host: x86_64-unknown-linux-gnu release: 1.79.0-nightly LLVM version: 18.1.4 ```` Command: `/home/matthias/.rustup/toolchains/master/bin/rustc ` Program output ``` error[E0412]: cannot find type `Sum` in this scope --> /tmp/icemaker_global_tempdir.g0OXoW02g0sV/rustc_testrunner_tmpdir_reporting.4mOsaGXo4NAR/mvce.rs:3:22 | 3 | UnusedByTheConst(Sum), | ^^^ not found in this scope | help: consider importing this trait | 1 + use std::iter::Sum; | error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.g0OXoW02g0sV/rustc_testrunner_tmpdir_reporting.4mOsaGXo4NAR/mvce.rs:6:30 | 6 | const EEK_ZERO: &[Eek] = &[]; | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.g0OXoW02g0sV/rustc_testrunner_tmpdir_reporting.4mOsaGXo4NAR/mvce.rs` error: internal compiler error: compiler/rustc_const_eval/src/interpret/eval_context.rs:1184:21: interpret const eval failure of Unevaluated(UnevaluatedConst { def: DefId(0:9 ~ mvce[ac98]::EEK_ZERO), args: [], promoted: Some(promoted[0]) }, &'{erased} [Eek; 0_usize]) which is not in required_consts thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/eval_context.rs:1184:21: Box stack backtrace: 0: 0x7f9cb8b4e145 - std::backtrace_rs::backtrace::libunwind::trace::h86d426b17d4e2e3d at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x7f9cb8b4e145 - std::backtrace_rs::backtrace::trace_unsynchronized::h8c0ef1d148b9d940 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f9cb8b4e145 - std::sys_common::backtrace::_print_fmt::he2abce7aa62cdc3a at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f9cb8b4e145 - ::fmt::h0c9241533158777f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f9cb8b9d21b - core::fmt::rt::Argument::fmt::h733dbde17a4a7d04 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/fmt/rt.rs:165:63 5: 0x7f9cb8b9d21b - core::fmt::write::h03896a7fdcd4b82f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/fmt/mod.rs:1157:21 6: 0x7f9cb8b42d4f - std::io::Write::write_fmt::hd74e7c0305df2660 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/io/mod.rs:1832:15 7: 0x7f9cb8b4df1e - std::sys_common::backtrace::_print::hea8c9c28ab87b1b7 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f9cb8b4df1e - std::sys_common::backtrace::print::hd4bb5623fa4b8de6 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f9cb8b50889 - std::panicking::default_hook::{{closure}}::h4623b55631f16943 10: 0x7f9cb8b505cd - std::panicking::default_hook::he5d3fa1d7e671103 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:298:9 11: 0x7f9cb54456ab - std[73cef507c0358b10]::panicking::update_hook::>::{closure#0} 12: 0x7f9cb8b50f86 - as core::ops::function::Fn>::call::h8ef97572a456b9c7 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2036:9 13: 0x7f9cb8b50f86 - std::panicking::rust_panic_with_hook::h1e2384e63ce90283 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:799:13 14: 0x7f9cb5475814 - std[73cef507c0358b10]::panicking::begin_panic::::{closure#0} 15: 0x7f9cb5472376 - std[73cef507c0358b10]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f9cb546d976 - std[73cef507c0358b10]::panicking::begin_panic:: 17: 0x7f9cb547ec51 - ::emit_producing_guarantee 18: 0x7f9cb592a79c - rustc_middle[65b49a3b5d6c0d49]::util::bug::opt_span_bug_fmt::::{closure#0} 19: 0x7f9cb591212a - rustc_middle[65b49a3b5d6c0d49]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 20: 0x7f9cb5911fab - rustc_middle[65b49a3b5d6c0d49]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 21: 0x7f9cb35581a0 - rustc_middle[65b49a3b5d6c0d49]::util::bug::bug_fmt 22: 0x7f9cb738877c - >::eval_rvalue_into_place 23: 0x7f9cb47ef0a8 - rustc_const_eval[fedc7aa5d50c96b6]::const_eval::eval_queries::eval_to_allocation_raw_provider 24: 0x7f9cb705b776 - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::> 25: 0x7f9cb705af99 - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::, rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false> 26: 0x7f9cb705ab6c - rustc_query_impl[e8a6f5b0469e51af]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace 27: 0x7f9cb705a702 - rustc_middle[65b49a3b5d6c0d49]::query::plumbing::query_get_at::, rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 24usize]>>> 28: 0x7f9cb7058afc - rustc_const_eval[fedc7aa5d50c96b6]::const_eval::eval_queries::eval_to_const_value_raw_provider 29: 0x7f9cb7058a76 - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::> 30: 0x7f9cb705af5c - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::, rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false> 31: 0x7f9cb705aa6c - rustc_query_impl[e8a6f5b0469e51af]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace 32: 0x7f9cb6be74d1 - ::par_body_owners::::{closure#0} 33: 0x7f9cb6be5b74 - rustc_hir_analysis[4525919e9da128a7]::check_crate 34: 0x7f9cb6bef507 - rustc_interface[b73225351c325ab5]::passes::analysis 35: 0x7f9cb6bef055 - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::> 36: 0x7f9cb75be665 - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false> 37: 0x7f9cb75be3c9 - rustc_query_impl[e8a6f5b0469e51af]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 38: 0x7f9cb7445993 - rustc_interface[b73225351c325ab5]::interface::run_compiler::, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1} 39: 0x7f9cb742f8e7 - std[73cef507c0358b10]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>> 40: 0x7f9cb742f6aa - <::spawn_unchecked_, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#2} as core[dad89120088e7e02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 41: 0x7f9cb8b5ae1b - as core::ops::function::FnOnce>::call_once::h3679caeb60ab03c2 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2022:9 42: 0x7f9cb8b5ae1b - as core::ops::function::FnOnce>::call_once::h7e27b57c37e0ef1f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2022:9 43: 0x7f9cb8b5ae1b - std::sys::pal::unix::thread::Thread::new::thread_start::he8797429d1c20e6e at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys/pal/unix/thread.rs:108:17 44: 0x7f9cb22a955a - 45: 0x7f9cb2326a3c - 46: 0x0 - 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 make sure that you have updated to the latest nightly note: rustc 1.79.0-nightly (7bb4f0889 2024-04-24) running on x86_64-unknown-linux-gnu query stack during panic: #0 [eval_to_allocation_raw] const-evaluating + checking `EEK_ZERO` #1 [eval_to_const_value_raw] simplifying constant for the type system `EEK_ZERO` #2 [analysis] running analysis passes on this crate end of query stack error: aborting due to 3 previous errors Some errors have detailed explanations: E0412, E0601. For more information about an error, try `rustc --explain E0412`. ```