Skip to content

Commit 67241bb

Browse files
committed
Inline WhereClause into Generics.
1 parent faadd8f commit 67241bb

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

clippy_lints/src/lifetimes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir::FnRetTy::Return;
88
use rustc_hir::{
99
BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem,
1010
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, TraitBoundModifier,
11-
TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WhereClause, WherePredicate,
11+
TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
1212
};
1313
use rustc_lint::{LateContext, LateLintPass};
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -130,7 +130,7 @@ fn check_fn_inner<'tcx>(
130130
span: Span,
131131
report_extra_lifetimes: bool,
132132
) {
133-
if span.from_expansion() || has_where_lifetimes(cx, &generics.where_clause) {
133+
if span.from_expansion() || has_where_lifetimes(cx, generics) {
134134
return;
135135
}
136136

@@ -445,8 +445,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
445445

446446
/// Are any lifetimes mentioned in the `where` clause? If so, we don't try to
447447
/// reason about elision.
448-
fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereClause<'_>) -> bool {
449-
for predicate in where_clause.predicates {
448+
fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, generics: &'tcx Generics<'_>) -> bool {
449+
for predicate in generics.predicates {
450450
match *predicate {
451451
WherePredicate::RegionPredicate(..) => return true,
452452
WherePredicate::BoundPredicate(ref pred) => {

clippy_lints/src/trait_bounds.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
9090
}
9191

9292
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'tcx>) {
93-
let Generics { where_clause, .. } = &item.generics;
9493
let mut self_bounds_map = FxHashMap::default();
9594

96-
for predicate in where_clause.predicates {
95+
for predicate in item.generics.predicates {
9796
if_chain! {
9897
if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate;
9998
if !bound_predicate.span.from_expansion();
@@ -166,7 +165,7 @@ impl TraitBounds {
166165
}
167166
let mut map: UnhashMap<SpanlessTy<'_, '_>, Vec<&GenericBound<'_>>> = UnhashMap::default();
168167
let mut applicability = Applicability::MaybeIncorrect;
169-
for bound in gen.where_clause.predicates {
168+
for bound in gen.predicates {
170169
if_chain! {
171170
if let WherePredicate::BoundPredicate(ref p) = bound;
172171
if p.bounds.len() as u64 <= self.max_trait_bounds;
@@ -216,7 +215,7 @@ impl TraitBounds {
216215
}
217216

218217
fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
219-
if gen.span.from_expansion() || gen.params.is_empty() || gen.where_clause.predicates.is_empty() {
218+
if gen.span.from_expansion() || gen.params.is_empty() || gen.predicates.is_empty() {
220219
return;
221220
}
222221

@@ -232,7 +231,7 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
232231
}
233232
}
234233

235-
for predicate in gen.where_clause.predicates {
234+
for predicate in gen.predicates {
236235
if_chain! {
237236
if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate;
238237
if !bound_predicate.span.from_expansion();

0 commit comments

Comments
 (0)