1
Fork 0

Auto merge of #99521 - fee1-dead-contrib:const_fix_hax, r=oli-obk

Fix hack that remaps env constness.

WARNING: might have perf implications.

Are there any more problems with having a constness in the `ParamEnv` now? :)

r? `@oli-obk`
This commit is contained in:
bors 2022-07-22 12:48:29 +00:00
commit 22d25f21dc
6 changed files with 46 additions and 67 deletions

View file

@ -575,6 +575,19 @@ impl<'tcx> Predicate<'tcx> {
Some(tcx.mk_predicate(kind))
}
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> Self {
if let PredicateKind::Trait(TraitPredicate { trait_ref, constness, polarity }) = self.kind().skip_binder()
&& constness != BoundConstness::NotConst
{
self = tcx.mk_predicate(self.kind().rebind(PredicateKind::Trait(TraitPredicate {
trait_ref,
constness: BoundConstness::NotConst,
polarity,
})));
}
self
}
}
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {