Skip to content

Commit fd6a4bb

Browse files
authored
Rollup merge of rust-lang#71276 - RalfJung:miri-unleash-box, r=ecstatic-morse
miri-unleashed: test that we detect heap allocations This removes the second-to-last use of `IS_SUPPORTED_IN_MIRI = false`. r? @ecstatic-morse @oli-obk
2 parents 14aa461 + cf3470a commit fd6a4bb

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/librustc_mir/transform/check_consts/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt;
1313

1414
pub use self::qualifs::Qualif;
1515

16-
pub mod ops;
16+
mod ops;
1717
pub mod qualifs;
1818
mod resolver;
1919
pub mod validation;

src/librustc_mir/transform/check_consts/ops.rs

-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ impl NonConstOp for FnCallUnstable {
113113
#[derive(Debug)]
114114
pub struct HeapAllocation;
115115
impl NonConstOp for HeapAllocation {
116-
const IS_SUPPORTED_IN_MIRI: bool = false;
117-
118116
fn emit_error(&self, item: &Item<'_, '_>, span: Span) {
119117
let mut err = struct_span_err!(
120118
item.tcx.sess,
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zunleash-the-miri-inside-of-you
2+
#![feature(const_mut_refs, box_syntax)]
3+
#![deny(const_err)]
4+
5+
use std::mem::ManuallyDrop;
6+
7+
fn main() {}
8+
9+
static TEST_BAD: &mut i32 = {
10+
&mut *(box 0)
11+
//~^ WARN skipping const check
12+
//~| ERROR could not evaluate static initializer
13+
//~| NOTE heap allocations
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
warning: skipping const checks
2+
--> $DIR/box.rs:10:11
3+
|
4+
LL | &mut *(box 0)
5+
| ^^^^^^^
6+
7+
error[E0080]: could not evaluate static initializer
8+
--> $DIR/box.rs:10:11
9+
|
10+
LL | &mut *(box 0)
11+
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
12+
13+
error: aborting due to previous error; 1 warning emitted
14+
15+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)