Closed
Description
auto-reduced (treereduce-rust):
const X: for<'b> fn(&'b ()) = |&()| ();
fn main() {
let dyn_debug = Box::new(X) as Box<fn(&'static ())> as Box<dyn Send>;
}
original:
//@ run-pass
//@ revisions: mir codegen
//@[mir] compile-flags: -Zmir-opt-level=3
//@[codegen] compile-flags: -Zmir-opt-level=0
// A regression test for #107205
const X: for<'b> fn(&'b ()) = |&()| ();
fn main() {
let dyn_debug = Box::new(X) as Box<fn(&'static ())> as Box<dyn Send>;
drop(dyn_debug)
}
Version information
rustc 1.79.0-nightly (00ed4edb4 2024-04-17)
binary: rustc
commit-hash: 00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82
commit-date: 2024-04-17
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zvirtual-function-elimination=true -Clto=true
Program output
warning: unused variable: `dyn_debug`
--> /tmp/icemaker_global_tempdir.8xGPA271RB07/rustc_testrunner_tmpdir_reporting.xnMiIiI7kJOB/mvce.rs:3:9
|
3 | let dyn_debug = Box::new(X) as Box<fn(&'static ())> as Box<dyn Send>;
| ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_dyn_debug`
|
= note: `#[warn(unused_variables)]` on by default
thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/meth.rs:77:37:
expected principal trait object
stack backtrace:
0: 0x77abee75ccd5 - std::backtrace_rs::backtrace::libunwind::trace::h0703e74daad28c72
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x77abee75ccd5 - std::backtrace_rs::backtrace::trace_unsynchronized::h25ed5cd2627369cf
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x77abee75ccd5 - std::sys_common::backtrace::_print_fmt::h469d42c17b595d59
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/sys_common/backtrace.rs:68:5
3: 0x77abee75ccd5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4b38e3480371ee05
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/sys_common/backtrace.rs:44:22
4: 0x77abee7abf9b - core::fmt::rt::Argument::fmt::haf74bdf42f86a86e
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/core/src/fmt/rt.rs:165:63
5: 0x77abee7abf9b - core::fmt::write::h3ae636f8b2626ce6
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/core/src/fmt/mod.rs:1157:21
6: 0x77abee7518df - std::io::Write::write_fmt::hf9a4f1c9d6e09581
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/io/mod.rs:1832:15
7: 0x77abee75caae - std::sys_common::backtrace::_print::h66bab3906cd40f88
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/sys_common/backtrace.rs:47:5
8: 0x77abee75caae - std::sys_common::backtrace::print::hd18c1231cf228a1b
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/sys_common/backtrace.rs:34:9
9: 0x77abee75f429 - std::panicking::default_hook::{{closure}}::h130a7699868564f4
10: 0x77abee75f16d - std::panicking::default_hook::h770af655f3cddf72
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/panicking.rs:291:9
11: 0x77abeb072b8c - std[537910c0bd201ce8]::panicking::update_hook::<alloc[92eb594650394d8e]::boxed::Box<rustc_driver_impl[ce7c3c359a362676]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x77abee75fb2c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5f454ec0e52ed414
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/alloc/src/boxed.rs:2036:9
13: 0x77abee75fb2c - std::panicking::rust_panic_with_hook::h77fbacc29d9a7d93
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/panicking.rs:792:13
14: 0x77abee75f8d6 - std::panicking::begin_panic_handler::{{closure}}::hfff1f5b59b8da58a
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/panicking.rs:657:13
15: 0x77abee75d199 - std::sys_common::backtrace::__rust_end_short_backtrace::h00ea868235fbef86
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/sys_common/backtrace.rs:171:18
16: 0x77abee75f607 - rust_begin_unwind
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/panicking.rs:645:5
17: 0x77abee7a8446 - core::panicking::panic_fmt::h83468d22ea7ff0a1
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/core/src/panicking.rs:72:14
18: 0x77abee7a85fc - core::panicking::panic_display::h8b6cc0415c5b118c
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/core/src/panicking.rs:256:5
19: 0x77abee7a81ec - core::panicking::panic_str::hff617a584c04d29d
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/core/src/panicking.rs:231:5
20: 0x77abee7a81ec - core::option::expect_failed::h843fcdeda94ac1db
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/core/src/option.rs:1994:5
21: 0x77abeafac119 - rustc_codegen_ssa[ae02e9f47c76e5c0]::meth::expect_dyn_trait_in_self
22: 0x77abedbff481 - <rustc_codegen_ssa[ae02e9f47c76e5c0]::meth::VirtualIndex>::get_fn::<rustc_codegen_llvm[9750cc59031b9897]::builder::Builder>.cold
23: 0x77abe926e197 - <rustc_codegen_ssa[ae02e9f47c76e5c0]::mir::FunctionCx<rustc_codegen_llvm[9750cc59031b9897]::builder::Builder>>::codegen_terminator
24: 0x77abed151f12 - rustc_codegen_ssa[ae02e9f47c76e5c0]::mir::codegen_mir::<rustc_codegen_llvm[9750cc59031b9897]::builder::Builder>
25: 0x77abed13e3ce - rustc_codegen_llvm[9750cc59031b9897]::base::compile_codegen_unit::module_codegen
26: 0x77abed13a616 - <rustc_codegen_llvm[9750cc59031b9897]::LlvmCodegenBackend as rustc_codegen_ssa[ae02e9f47c76e5c0]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
27: 0x77abed409e67 - rustc_codegen_ssa[ae02e9f47c76e5c0]::base::codegen_crate::<rustc_codegen_llvm[9750cc59031b9897]::LlvmCodegenBackend>
28: 0x77abed2eaf34 - <rustc_codegen_llvm[9750cc59031b9897]::LlvmCodegenBackend as rustc_codegen_ssa[ae02e9f47c76e5c0]::traits::backend::CodegenBackend>::codegen_crate
29: 0x77abed2ea89d - rustc_interface[6da10dd202fdb9b4]::passes::start_codegen
30: 0x77abed2e9f18 - <rustc_interface[6da10dd202fdb9b4]::queries::Queries>::codegen_and_build_linker
31: 0x77abed0c10fc - rustc_interface[6da10dd202fdb9b4]::interface::run_compiler::<core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>, rustc_driver_impl[ce7c3c359a362676]::run_compiler::{closure#0}>::{closure#1}
32: 0x77abed072ea7 - std[537910c0bd201ce8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6da10dd202fdb9b4]::util::run_in_thread_with_globals<rustc_interface[6da10dd202fdb9b4]::util::run_in_thread_pool_with_globals<rustc_interface[6da10dd202fdb9b4]::interface::run_compiler<core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>, rustc_driver_impl[ce7c3c359a362676]::run_compiler::{closure#0}>::{closure#1}, core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>>::{closure#0}, core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>>
33: 0x77abed072c6a - <<std[537910c0bd201ce8]::thread::Builder>::spawn_unchecked_<rustc_interface[6da10dd202fdb9b4]::util::run_in_thread_with_globals<rustc_interface[6da10dd202fdb9b4]::util::run_in_thread_pool_with_globals<rustc_interface[6da10dd202fdb9b4]::interface::run_compiler<core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>, rustc_driver_impl[ce7c3c359a362676]::run_compiler::{closure#0}>::{closure#1}, core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>>::{closure#0}, core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e932fa5924b4d1b7]::result::Result<(), rustc_span[a340915128aea4cf]::ErrorGuaranteed>>::{closure#2} as core[e932fa5924b4d1b7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x77abee769a1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he6b356c71c632967
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/alloc/src/boxed.rs:2022:9
35: 0x77abee769a1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6c29e09c486110af
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/alloc/src/boxed.rs:2022:9
36: 0x77abee769a1b - std::sys::pal::unix::thread::Thread::new::thread_start::h8f690723e033c81d
at /rustc/00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82/library/std/src/sys/pal/unix/thread.rs:108:17
37: 0x77abe7ea955a - <unknown>
38: 0x77abe7f26a3c - <unknown>
39: 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 make sure that you have updated to the latest nightly
note: rustc 1.79.0-nightly (00ed4edb4 2024-04-17) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z virtual-function-elimination=true -C lto=true -Z dump-mir-dir=dir
query stack during panic:
end of query stack
warning: 1 warning emitted