Rollup merge of #147764 - beepster4096:oopsies_sorry, r=saethlin

Undo CopyForDeref assertion in const qualif

Fixes rust-lang/rust#147733 caused by rust-lang/rust#145513

This code in fact does not run only on runtime MIR.
This commit is contained in:
Matthias Krüger 2025-10-18 08:08:38 +02:00 committed by GitHub
commit 756d3a0fb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 1 deletions

View file

@ -234,7 +234,7 @@ where
Rvalue::Discriminant(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),
Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in runtime MIR"),
Rvalue::CopyForDeref(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),
Rvalue::Use(operand)
| Rvalue::Repeat(operand, _)

View file

@ -0,0 +1,15 @@
//! Tests that multiple derefs in a projection does not cause an ICE
//! when checking const precise drops.
//!
//! Regression test for <https://github.com/rust-lang/rust/issues/147733>
#![feature(const_precise_live_drops)]
struct Foo(u32);
impl Foo {
const fn get(self: Box<&Self>, f: &u32) -> u32 {
//~^ ERROR destructor of `Box<&Foo>` cannot be evaluated at compile-time
self.0
}
}
fn main() {}

View file

@ -0,0 +1,12 @@
error[E0493]: destructor of `Box<&Foo>` cannot be evaluated at compile-time
--> $DIR/precise-drop-nested-deref-ice.rs:9:18
|
LL | const fn get(self: Box<&Self>, f: &u32) -> u32 {
| ^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0493`.