Skip to content

Commit 756d3a0

Browse files
authored
Rollup merge of #147764 - beepster4096:oopsies_sorry, r=saethlin
Undo CopyForDeref assertion in const qualif Fixes #147733 caused by #145513 This code in fact does not run only on runtime MIR.
2 parents fc65029 + 5ffbec8 commit 756d3a0

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ where
234234

235235
Rvalue::Discriminant(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),
236236

237-
Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in runtime MIR"),
237+
Rvalue::CopyForDeref(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),
238238

239239
Rvalue::Use(operand)
240240
| Rvalue::Repeat(operand, _)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Tests that multiple derefs in a projection does not cause an ICE
2+
//! when checking const precise drops.
3+
//!
4+
//! Regression test for <https://github.com/rust-lang/rust/issues/147733>
5+
6+
#![feature(const_precise_live_drops)]
7+
struct Foo(u32);
8+
impl Foo {
9+
const fn get(self: Box<&Self>, f: &u32) -> u32 {
10+
//~^ ERROR destructor of `Box<&Foo>` cannot be evaluated at compile-time
11+
self.0
12+
}
13+
}
14+
15+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0493]: destructor of `Box<&Foo>` cannot be evaluated at compile-time
2+
--> $DIR/precise-drop-nested-deref-ice.rs:9:18
3+
|
4+
LL | const fn get(self: Box<&Self>, f: &u32) -> u32 {
5+
| ^^^^ the destructor for this type cannot be evaluated in constant functions
6+
...
7+
LL | }
8+
| - value is dropped here
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0493`.

0 commit comments

Comments
 (0)