Skip to content

Commit 23b5516

Browse files
committed
Auto merge of #51852 - oli-obk:miri_fix, r=Zoxc
Don't use `ParamEnv::reveal_all()` if there is a real one available fixes #51841 r? @Zoxc
2 parents 4aff10b + 89d8e0a commit 23b5516

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/librustc_mir/interpret/const_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn value_to_const_value<'tcx>(
7676
val: Value,
7777
ty: Ty<'tcx>,
7878
) -> &'tcx ty::Const<'tcx> {
79-
let layout = ecx.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap();
79+
let layout = ecx.layout_of(ty).unwrap();
8080
match (val, &layout.abi) {
8181
(Value::Scalar(Scalar::Bits { defined: 0, ..}), _) if layout.is_zst() => {},
8282
(Value::ByRef(..), _) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
pub trait Nullable {
14+
const NULL: Self;
15+
16+
fn is_null(&self) -> bool;
17+
}
18+
19+
impl<T> Nullable for *const T {
20+
const NULL: Self = 0 as *const T;
21+
22+
fn is_null(&self) -> bool {
23+
*self == Self::NULL
24+
}
25+
}
26+
27+
fn main() {
28+
}

0 commit comments

Comments
 (0)