about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-06-27 19:30:14 +0000
committerbors <bors@rust-lang.org>2018-06-27 19:30:14 +0000
commit23b55161ab4cb6d4bf868ac575bd174ca2de0ffa (patch)
tree56192aeb58e8ee61a7fe44c540a3846a8c3ae5b1
parent4aff10bb1b9b202bb6464f99d198d3e6f49e6991 (diff)
parent89d8e0a2606a77edcc73533e4aee96c5a728a79f (diff)
downloadrust-23b55161ab4cb6d4bf868ac575bd174ca2de0ffa.tar.gz
rust-23b55161ab4cb6d4bf868ac575bd174ca2de0ffa.zip
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
-rw-r--r--src/librustc_mir/interpret/const_eval.rs2
-rw-r--r--src/test/ui/const-eval/ice-generic-assoc-const.rs28
2 files changed, 29 insertions, 1 deletions
diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs
index 3fcf1b5c8ed..592c9dbe6ff 100644
--- a/src/librustc_mir/interpret/const_eval.rs
+++ b/src/librustc_mir/interpret/const_eval.rs
@@ -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(..), _) |
diff --git a/src/test/ui/const-eval/ice-generic-assoc-const.rs b/src/test/ui/const-eval/ice-generic-assoc-const.rs
new file mode 100644
index 00000000000..31e056b66bc
--- /dev/null
+++ b/src/test/ui/const-eval/ice-generic-assoc-const.rs
@@ -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() {
+}