1
Fork 0

Fix perf issue for auto trait selection

This commit is contained in:
Guillaume Gomez 2022-03-26 14:58:19 +01:00
parent 3fe3b89cd5
commit ad88732254
3 changed files with 29 additions and 2 deletions

View file

@ -999,6 +999,15 @@ impl<'tcx> PolyTraitRef<'tcx> {
polarity: ty::ImplPolarity::Positive,
})
}
/// Same as [`PolyTraitRef::to_poly_trait_predicate`] but sets a negative polarity instead.
pub fn to_poly_trait_predicate_negative_polarity(&self) -> ty::PolyTraitPredicate<'tcx> {
self.map_bound(|trait_ref| ty::TraitPredicate {
trait_ref,
constness: ty::BoundConstness::NotConst,
polarity: ty::ImplPolarity::Negative,
})
}
}
/// An existential reference to a trait, where `Self` is erased.