diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index a37fa1308137..e5e47a51e8da 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -2298,6 +2298,7 @@ impl<'tcx> Const<'tcx> { ty: Ty<'tcx>, ) -> Option { assert_eq!(self.ty, ty); + // if `ty` does not depend on generic parameters, use an empty param_env let size = tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size; match self.val { // FIXME(const_generics): this doesn't work right now, @@ -2315,8 +2316,7 @@ impl<'tcx> Const<'tcx> { let evaluated = tcx.const_eval(param_env.and(gid)).ok()?; evaluated.val.try_to_bits(size) }, - // FIXME(const_generics): try to evaluate generic consts with a given param env? - // E.g. when you have an associated constant whose value depends on a generic const + // otherwise just extract a `ConstValue`'s bits if possible _ => self.val.try_to_bits(size), } } diff --git a/src/test/ui/consts/self_normalization.rs b/src/test/ui/consts/self_normalization.rs index e11e8b4318e8..93aadda1ec53 100644 --- a/src/test/ui/consts/self_normalization.rs +++ b/src/test/ui/consts/self_normalization.rs @@ -1,6 +1,6 @@ // compile-pass -fn testfn(_arr: &mut [();0]) {} +fn testfn(_arr: &mut [(); 0]) {} trait TestTrait { fn method();