diff options
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/const_evaluatable.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/const_evaluatable.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 50cc2afb89c..1a5139d34d3 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -142,6 +142,12 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { return None; } + // We don't have to look at concrete constants, as we + // can just evaluate them. + if !body.is_polymorphic { + return None; + } + Some(AbstractConstBuilder { tcx, body, @@ -304,6 +310,15 @@ pub(super) fn mir_abstract_const<'tcx>( def: ty::WithOptConstParam<LocalDefId>, ) -> Option<&'tcx [Node<'tcx>]> { if tcx.features().const_evaluatable_checked { + match tcx.def_kind(def.did) { + // FIXME(const_evaluatable_checked): We currently only do this for anonymous constants, + // meaning that we do not look into associated constants. I(@lcnr) am not yet sure whether + // we want to look into them or treat them as opaque projections. + // + // Right now we do neither of that and simply always fail to unify them. + DefKind::AnonConst => (), + _ => return None, + } let body = tcx.mir_const(def).borrow(); AbstractConstBuilder::new(tcx, &body)?.build() } else { |
