1
Fork 0

Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk

Require `#[const_trait]` on `Trait` for `impl const Trait`

r? `@oli-obk`
This commit is contained in:
bors 2022-09-22 04:22:24 +00:00
commit 7a8636c843
80 changed files with 433 additions and 245 deletions

View file

@ -67,6 +67,14 @@ impl<'tcx> PredicateObligation<'tcx> {
recursion_depth: self.recursion_depth,
})
}
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> PredicateObligation<'tcx> {
self.param_env = self.param_env.without_const();
if let ty::PredicateKind::Trait(trait_pred) = self.predicate.kind().skip_binder() && trait_pred.is_const_if_const() {
self.predicate = tcx.mk_predicate(self.predicate.kind().map_bound(|_| ty::PredicateKind::Trait(trait_pred.without_const())));
}
self
}
}
impl<'tcx> TraitObligation<'tcx> {