Skip to content

Commit 1c8ce6a

Browse files
committed
fix small perf regressions
1 parent 5cb86fe commit 1c8ce6a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compiler/rustc_middle/src/infer/canonical.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::ops::Index;
3434
use crate::infer::MemberConstraint;
3535
use crate::mir::ConstraintCategory;
3636
use 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

3939
pub 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

Comments
 (0)