Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _)
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/consts/precise-drop-nested-deref-ice.rs
Original file line number Diff line number Diff line change
@@ -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() {}
12 changes: 12 additions & 0 deletions tests/ui/consts/precise-drop-nested-deref-ice.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Loading