-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
C-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) ❄️T-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
auto-reduced (treereduce-rust):
#![feature(const_precise_live_drops)]
struct Foo(u32);
impl Foo {
const fn get(self: Box<&Self>, f: &u32) -> u32 {
self.0
}
}
original:
//! The same as the non-ICE test, but const eval will run typeck of
//! `get` before running wfcheck (as that may in itself trigger const
//! eval again, and thus cause bogus cycles). This used to ICE because
//! we asserted that an error had already been emitted.
use std::ops::Deref;
struct Foo(u32);
impl Foo {
const fn get<R: Deref<Target = Self>>(self: Box<&Self>, f: &u32) -> u32 {
//~^ ERROR invalid generic `self` parameter type
//~| ERROR destructor of `R` cannot be evaluated at compile-time
self.0
//~^ ERROR cannot perform non-const deref coercion on `R` in constant functions
}
}
const FOO: () = {
let foo = Foo(1);
foo.get::<&Foo>();
};
const BAR: [(); {
FOO;
0
}] = [];
fn main() {}
Version information
rustc 1.92.0-nightly (5413f7d39 2025-10-15)
binary: rustc
commit-hash: 5413f7d39cae07b7b3809973fe201d21960a18aa
commit-date: 2025-10-15
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.3
Possibly related line of code:
rust/compiler/rustc_const_eval/src/check_consts/qualifs.rs
Lines 231 to 243 in 5413f7d
Rvalue::ThreadLocalRef(_) | Rvalue::NullaryOp(..) => { | |
Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)) | |
} | |
Rvalue::Discriminant(place) => in_place::<Q, _>(cx, in_local, place.as_ref()), | |
Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in runtime MIR"), | |
Rvalue::Use(operand) | |
| Rvalue::Repeat(operand, _) | |
| Rvalue::UnaryOp(_, operand) | |
| Rvalue::Cast(_, operand, _) | |
| Rvalue::ShallowInitBox(operand, _) => in_operand::<Q, _>(cx, in_local, operand), |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(const_precise_live_drops)
Program output
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.tYoJFgp7qDA7/rustc_testrunner_tmpdir_reporting.g9GoYo458vg6/mvce.rs:6:2
|
6 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.tYoJFgp7qDA7/rustc_testrunner_tmpdir_reporting.g9GoYo458vg6/mvce.rs`
warning: unused variable: `f`
--> /tmp/icemaker_global_tempdir.tYoJFgp7qDA7/rustc_testrunner_tmpdir_reporting.g9GoYo458vg6/mvce.rs:3:36
|
3 | const fn get(self: Box<&Self>, f: &u32) -> u32 {
| ^ help: if this is intentional, prefix it with an underscore: `_f`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
error: internal compiler error: compiler/rustc_const_eval/src/check_consts/qualifs.rs:237:36: `CopyForDeref` in runtime MIR
thread 'rustc' (2041939) panicked at compiler/rustc_const_eval/src/check_consts/qualifs.rs:237:36:
Box<dyn Any>
stack backtrace:
0: 0x7f37087f6283 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb3d81af859b83823
1: 0x7f3708e0203c - core::fmt::write::h2f34fbe6620ce917
2: 0x7f37087aa613 - std::io::Write::write_fmt::h002c806892ce67ba
3: 0x7f37087bb942 - std::sys::backtrace::BacktraceLock::print::h28a638c4c38e3350
4: 0x7f37087c1a19 - std::panicking::default_hook::{{closure}}::h9c85d97665588a7b
5: 0x7f37087c1543 - std::panicking::default_hook::h9d658d29c3343f12
6: 0x7f37077ce4c7 - std[610ee9f2d7645267]::panicking::update_hook::<alloc[6db01716c1493b41]::boxed::Box<rustc_driver_impl[fe72b4b08a838243]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f37087c1e3f - std::panicking::panic_with_hook::h71843a354f80e757
8: 0x7f3707808c71 - std[610ee9f2d7645267]::panicking::begin_panic::<rustc_errors[a119ed1d478cb7e6]::ExplicitBug>::{closure#0}
9: 0x7f37077fc4e6 - std[610ee9f2d7645267]::sys::backtrace::__rust_end_short_backtrace::<std[610ee9f2d7645267]::panicking::begin_panic<rustc_errors[a119ed1d478cb7e6]::ExplicitBug>::{closure#0}, !>
10: 0x7f37077f9f99 - std[610ee9f2d7645267]::panicking::begin_panic::<rustc_errors[a119ed1d478cb7e6]::ExplicitBug>
11: 0x7f37078141e1 - <rustc_errors[a119ed1d478cb7e6]::diagnostic::BugAbort as rustc_errors[a119ed1d478cb7e6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7f3707daccea - rustc_middle[ac76b9677f9ac18a]::util::bug::opt_span_bug_fmt::<rustc_span[69e6be4d3d41ab04]::span_encoding::Span>::{closure#0}
13: 0x7f3707daceaa - rustc_middle[ac76b9677f9ac18a]::ty::context::tls::with_opt::<rustc_middle[ac76b9677f9ac18a]::util::bug::opt_span_bug_fmt<rustc_span[69e6be4d3d41ab04]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7f3707d9b97b - rustc_middle[ac76b9677f9ac18a]::ty::context::tls::with_context_opt::<rustc_middle[ac76b9677f9ac18a]::ty::context::tls::with_opt<rustc_middle[ac76b9677f9ac18a]::util::bug::opt_span_bug_fmt<rustc_span[69e6be4d3d41ab04]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7f3706648ed0 - rustc_middle[ac76b9677f9ac18a]::util::bug::bug_fmt
16: 0x7f370aaa39d0 - <rustc_const_eval[940213010afd08f2]::check_consts::resolver::FlowSensitiveAnalysis<rustc_const_eval[940213010afd08f2]::check_consts::qualifs::NeedsDrop> as rustc_mir_dataflow[d382e49d70b77820]::framework::Analysis>::apply_primary_statement_effect.cold
17: 0x7f37098e9f3a - <rustc_const_eval[940213010afd08f2]::check_consts::check::Qualifs>::needs_drop
18: 0x7f3709b237ca - <rustc_const_eval[940213010afd08f2]::check_consts::check::Checker>::check_drop_terminator
19: 0x7f3707765ee7 - rustc_const_eval[940213010afd08f2]::check_consts::post_drop_elaboration::check_live_drops
20: 0x7f3709a2f3dc - rustc_mir_transform[ca53f2db41b60c32]::pass_manager::run_passes_inner
21: 0x7f3708e0aa26 - rustc_mir_transform[ca53f2db41b60c32]::run_analysis_to_runtime_passes
22: 0x7f370919c7d5 - rustc_mir_transform[ca53f2db41b60c32]::mir_drops_elaborated_and_const_checked
23: 0x7f370919c163 - rustc_query_impl[402ef36c210111dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[402ef36c210111dc]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ac76b9677f9ac18a]::query::erase::Erased<[u8; 8usize]>>
24: 0x7f3709198cf7 - rustc_query_system[5b5b56fbc4740c12]::query::plumbing::try_execute_query::<rustc_query_impl[402ef36c210111dc]::DynamicConfig<rustc_data_structures[888b0f66650d342b]::vec_cache::VecCache<rustc_span[69e6be4d3d41ab04]::def_id::LocalDefId, rustc_middle[ac76b9677f9ac18a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5b5b56fbc4740c12]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[402ef36c210111dc]::plumbing::QueryCtxt, false>
25: 0x7f3709198389 - rustc_query_impl[402ef36c210111dc]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
26: 0x7f3709197365 - <rustc_middle[ac76b9677f9ac18a]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[8aeed5d7916aa52e]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
27: 0x7f3709192baa - rustc_interface[8aeed5d7916aa52e]::passes::analysis
28: 0x7f3709192033 - rustc_query_impl[402ef36c210111dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[402ef36c210111dc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ac76b9677f9ac18a]::query::erase::Erased<[u8; 0usize]>>
29: 0x7f3709df6c26 - rustc_query_system[5b5b56fbc4740c12]::query::plumbing::try_execute_query::<rustc_query_impl[402ef36c210111dc]::DynamicConfig<rustc_query_system[5b5b56fbc4740c12]::query::caches::SingleCache<rustc_middle[ac76b9677f9ac18a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[402ef36c210111dc]::plumbing::QueryCtxt, false>
30: 0x7f3709df687c - rustc_query_impl[402ef36c210111dc]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
31: 0x7f370a15e2a6 - <rustc_interface[8aeed5d7916aa52e]::passes::create_and_enter_global_ctxt<core[953a9a38396fade]::option::Option<rustc_interface[8aeed5d7916aa52e]::queries::Linker>, rustc_driver_impl[fe72b4b08a838243]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[953a9a38396fade]::ops::function::FnOnce<(&rustc_session[f386196aafdf2681]::session::Session, rustc_middle[ac76b9677f9ac18a]::ty::context::CurrentGcx, alloc[6db01716c1493b41]::sync::Arc<rustc_data_structures[888b0f66650d342b]::jobserver::Proxy>, &std[610ee9f2d7645267]::sync::once_lock::OnceLock<rustc_middle[ac76b9677f9ac18a]::ty::context::GlobalCtxt>, &rustc_data_structures[888b0f66650d342b]::sync::worker_local::WorkerLocal<rustc_middle[ac76b9677f9ac18a]::arena::Arena>, &rustc_data_structures[888b0f66650d342b]::sync::worker_local::WorkerLocal<rustc_hir[36652edee19d43e6]::Arena>, rustc_driver_impl[fe72b4b08a838243]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
32: 0x7f3709f8e700 - rustc_interface[8aeed5d7916aa52e]::interface::run_compiler::<(), rustc_driver_impl[fe72b4b08a838243]::run_compiler::{closure#0}>::{closure#1}
33: 0x7f370a0bdf89 - std[610ee9f2d7645267]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8aeed5d7916aa52e]::util::run_in_thread_with_globals<rustc_interface[8aeed5d7916aa52e]::util::run_in_thread_pool_with_globals<rustc_interface[8aeed5d7916aa52e]::interface::run_compiler<(), rustc_driver_impl[fe72b4b08a838243]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
34: 0x7f370a0bdc6a - <<std[610ee9f2d7645267]::thread::Builder>::spawn_unchecked_<rustc_interface[8aeed5d7916aa52e]::util::run_in_thread_with_globals<rustc_interface[8aeed5d7916aa52e]::util::run_in_thread_pool_with_globals<rustc_interface[8aeed5d7916aa52e]::interface::run_compiler<(), rustc_driver_impl[fe72b4b08a838243]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[953a9a38396fade]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
35: 0x7f3709b3abef - std::sys::thread::unix::Thread::new::thread_start::h2020f9803bcaea96
36: 0x7f37038969cb - <unknown>
37: 0x7f370391aa0c - <unknown>
38: 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: please make sure that you have updated to the latest nightly
note: rustc 1.92.0-nightly (5413f7d39 2025-10-15) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z crate-attr=feature(const_precise_live_drops) -Z dump-mir-dir=dir
query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `<impl at /tmp/icemaker_global_tempdir.tYoJFgp7qDA7/rustc_testrunner_tmpdir_reporting.g9GoYo458vg6/mvce.rs:2:1: 2:9>::get`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0601`.
@rustbot label +F-const_precise_live_drops
Metadata
Metadata
Assignees
Labels
C-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) ❄️T-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.