diff options
| author | Frank King <frankking1729@gmail.com> | 2025-02-05 18:58:29 +0800 |
|---|---|---|
| committer | Frank King <frankking1729@gmail.com> | 2025-03-01 22:02:46 +0800 |
| commit | cac9e0ab60c9c3498426a2a988d23ade483139bb (patch) | |
| tree | bf82aeaf155c30e5fb02e27653e7b1fbf7986d15 | |
| parent | 222aaba5a18a27f747573aa73d07d7fedfff0231 (diff) | |
| download | rust-cac9e0ab60c9c3498426a2a988d23ade483139bb.tar.gz rust-cac9e0ab60c9c3498426a2a988d23ade483139bb.zip | |
Implment `#[cfg]` and `#[cfg_attr]` in `where` clauses
| -rw-r--r-- | clippy_utils/src/ast_utils/mod.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/clippy_utils/src/ast_utils/mod.rs b/clippy_utils/src/ast_utils/mod.rs index ab5f97199ce..4f024ecaf29 100644 --- a/clippy_utils/src/ast_utils/mod.rs +++ b/clippy_utils/src/ast_utils/mod.rs @@ -682,19 +682,20 @@ pub fn eq_generics(l: &Generics, r: &Generics) -> bool { pub fn eq_where_predicate(l: &WherePredicate, r: &WherePredicate) -> bool { use WherePredicateKind::*; - match (&l.kind, &r.kind) { - (BoundPredicate(l), BoundPredicate(r)) => { - over(&l.bound_generic_params, &r.bound_generic_params, |l, r| { - eq_generic_param(l, r) - }) && eq_ty(&l.bounded_ty, &r.bounded_ty) - && over(&l.bounds, &r.bounds, eq_generic_bound) - }, - (RegionPredicate(l), RegionPredicate(r)) => { - eq_id(l.lifetime.ident, r.lifetime.ident) && over(&l.bounds, &r.bounds, eq_generic_bound) - }, - (EqPredicate(l), EqPredicate(r)) => eq_ty(&l.lhs_ty, &r.lhs_ty) && eq_ty(&l.rhs_ty, &r.rhs_ty), - _ => false, - } + over(&l.attrs, &r.attrs, eq_attr) + && match (&l.kind, &r.kind) { + (BoundPredicate(l), BoundPredicate(r)) => { + over(&l.bound_generic_params, &r.bound_generic_params, |l, r| { + eq_generic_param(l, r) + }) && eq_ty(&l.bounded_ty, &r.bounded_ty) + && over(&l.bounds, &r.bounds, eq_generic_bound) + }, + (RegionPredicate(l), RegionPredicate(r)) => { + eq_id(l.lifetime.ident, r.lifetime.ident) && over(&l.bounds, &r.bounds, eq_generic_bound) + }, + (EqPredicate(l), EqPredicate(r)) => eq_ty(&l.lhs_ty, &r.lhs_ty) && eq_ty(&l.rhs_ty, &r.rhs_ty), + _ => false, + } } pub fn eq_use_tree(l: &UseTree, r: &UseTree) -> bool { |
