Skip to content

Commit

Permalink
Auto merge of #51852 - oli-obk:miri_fix, r=Zoxc
Browse files Browse the repository at this point in the history
Don't use `ParamEnv::reveal_all()` if there is a real one available

fixes #51841

r? @Zoxc
  • Loading branch information
bors committed Jun 27, 2018
2 parents 4aff10b + 89d8e0a commit 23b5516
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn value_to_const_value<'tcx>(
val: Value,
ty: Ty<'tcx>,
) -> &'tcx ty::Const<'tcx> {
let layout = ecx.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap();
let layout = ecx.layout_of(ty).unwrap();
match (val, &layout.abi) {
(Value::Scalar(Scalar::Bits { defined: 0, ..}), _) if layout.is_zst() => {},
(Value::ByRef(..), _) |
Expand Down
28 changes: 28 additions & 0 deletions src/test/ui/const-eval/ice-generic-assoc-const.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-pass

pub trait Nullable {
const NULL: Self;

fn is_null(&self) -> bool;
}

impl<T> Nullable for *const T {
const NULL: Self = 0 as *const T;

fn is_null(&self) -> bool {
*self == Self::NULL
}
}

fn main() {
}

0 comments on commit 23b5516

Please sign in to comment.