diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index 3fcf1b5c8ed59..592c9dbe6ffe4 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 0000000000000..31e056b66bce9 --- /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 or the MIT license +// , 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 Nullable for *const T { + const NULL: Self = 0 as *const T; + + fn is_null(&self) -> bool { + *self == Self::NULL + } +} + +fn main() { +}