Don't transform predicates in Inherited

This commit is contained in:
Deadbeef 2021-07-26 12:06:32 +08:00
parent c6d0a20f7b
commit 7106f8d8ee
No known key found for this signature in database
GPG key ID: 027DF9338862ADDD

View file

@ -126,24 +126,8 @@ impl Inherited<'a, 'tcx> {
}
}
#[instrument(level = "debug", skip(self))]
fn transform_predicate(&self, p: &mut ty::Predicate<'tcx>) {
// Don't transform non-const bounds into const bounds,
// but transform const bounds to non-const when we are
// not in a const context.
if let hir::Constness::NotConst = self.constness {
let kind = p.kind();
if let ty::PredicateKind::Trait(pred) = kind.as_ref().skip_binder() {
let mut pred = *pred;
pred.constness = hir::Constness::NotConst;
*p = kind.rebind(ty::PredicateKind::Trait(pred)).to_predicate(self.tcx);
}
}
}
pub(super) fn register_predicate(&self, mut obligation: traits::PredicateObligation<'tcx>) {
pub(super) fn register_predicate(&self, obligation: traits::PredicateObligation<'tcx>) {
debug!("register_predicate({:?})", obligation);
self.transform_predicate(&mut obligation.predicate);
if obligation.has_escaping_bound_vars() {
span_bug!(obligation.cause.span, "escaping bound vars in predicate {:?}", obligation);
}