@@ -34,7 +34,7 @@ use std::ops::Index;
3434use crate :: infer:: MemberConstraint ;
3535use crate :: mir:: ConstraintCategory ;
3636use crate :: ty:: GenericArg ;
37- use crate :: ty:: { self , BoundVar , List , Region , Ty , TyCtxt } ;
37+ use crate :: ty:: { self , BoundVar , List , Region , Ty , TyCtxt , TypeFlags , TypeVisitableExt } ;
3838
3939pub type Canonical < ' tcx , V > = IrCanonical < TyCtxt < ' tcx > , V > ;
4040
@@ -315,6 +315,16 @@ impl<'tcx> CanonicalParamEnvCache<'tcx> {
315315 & mut OriginalQueryValues < ' tcx > ,
316316 ) -> Canonical < ' tcx , ty:: ParamEnv < ' tcx > > ,
317317 ) -> Canonical < ' tcx , ty:: ParamEnv < ' tcx > > {
318+ if !key. has_type_flags (
319+ TypeFlags :: HAS_INFER | TypeFlags :: HAS_PLACEHOLDER | TypeFlags :: HAS_FREE_REGIONS ,
320+ ) {
321+ return Canonical {
322+ max_universe : ty:: UniverseIndex :: ROOT ,
323+ variables : List :: empty ( ) ,
324+ value : key,
325+ } ;
326+ }
327+
318328 assert_eq ! ( state. var_values. len( ) , 0 ) ;
319329 assert_eq ! ( state. universe_map. len( ) , 1 ) ;
320330 debug_assert_eq ! ( & * state. universe_map, & [ ty:: UniverseIndex :: ROOT ] ) ;
0 commit comments