1
Fork 0

Track if a where bound comes from a impl Trait desugar

With #93803 `impl Trait` function arguments get desugared to hidden
where bounds. However, Clippy needs to know if a bound was originally a
impl Trait or an actual bound. This adds a field to the
`WhereBoundPredicate` struct to keep track of this information during
HIR lowering.
This commit is contained in:
flip1995 2022-05-05 15:50:11 +01:00 committed by flip1995
parent f47d2b3ad6
commit dd1ff405e3
No known key found for this signature in database
GPG key ID: 2CEFCDB27ED0BE79
7 changed files with 34 additions and 12 deletions

View file

@ -706,7 +706,7 @@ impl<'hir> WherePredicate<'hir> {
pub fn in_where_clause(&self) -> bool {
match self {
WherePredicate::BoundPredicate(p) => p.in_where_clause,
WherePredicate::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
WherePredicate::RegionPredicate(p) => p.in_where_clause,
WherePredicate::EqPredicate(_) => false,
}
@ -721,11 +721,19 @@ impl<'hir> WherePredicate<'hir> {
}
}
#[derive(Debug, HashStable_Generic, PartialEq, Eq)]
pub enum PredicateOrigin {
WhereClause,
GenericParam,
ImplTrait,
}
/// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`).
#[derive(Debug, HashStable_Generic)]
pub struct WhereBoundPredicate<'hir> {
pub span: Span,
pub in_where_clause: bool,
/// Origin of the predicate.
pub origin: PredicateOrigin,
/// Any generics from a `for` binding.
pub bound_generic_params: &'hir [GenericParam<'hir>],
/// The type being bounded.