@@ -11,7 +11,7 @@ use rustc_errors::Applicability;
11
11
use rustc_hir:: def:: Res ;
12
12
use rustc_hir:: {
13
13
BoundPolarity , GenericBound , Generics , Item , ItemKind , LangItem , Node , Path , PathSegment , PredicateOrigin , QPath ,
14
- TraitBoundModifiers , TraitItem , TraitRef , Ty , TyKind , WherePredicate ,
14
+ TraitBoundModifiers , TraitItem , TraitRef , Ty , TyKind , WherePredicateKind ,
15
15
} ;
16
16
use rustc_lint:: { LateContext , LateLintPass } ;
17
17
use rustc_session:: impl_lint_pass;
@@ -124,9 +124,9 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
124
124
let mut self_bounds_map = FxHashMap :: default ( ) ;
125
125
126
126
for predicate in item. generics . predicates {
127
- if let WherePredicate :: BoundPredicate ( bound_predicate) = predicate
127
+ if let WherePredicateKind :: BoundPredicate ( bound_predicate) = predicate. kind
128
128
&& bound_predicate. origin != PredicateOrigin :: ImplTrait
129
- && !bound_predicate . span . from_expansion ( )
129
+ && !predicate . span . from_expansion ( )
130
130
&& let TyKind :: Path ( QPath :: Resolved ( _, Path { segments, .. } ) ) = bound_predicate. bounded_ty . kind
131
131
&& let Some ( PathSegment {
132
132
res : Res :: SelfTyParam { trait_ : def_id } ,
@@ -268,10 +268,10 @@ impl TraitBounds {
268
268
let mut map: UnhashMap < SpanlessTy < ' _ , ' _ > , Vec < & GenericBound < ' _ > > > = UnhashMap :: default ( ) ;
269
269
let mut applicability = Applicability :: MaybeIncorrect ;
270
270
for bound in generics. predicates {
271
- if let WherePredicate :: BoundPredicate ( p) = bound
271
+ if let WherePredicateKind :: BoundPredicate ( p) = bound. kind
272
272
&& p. origin != PredicateOrigin :: ImplTrait
273
273
&& p. bounds . len ( ) as u64 <= self . max_trait_bounds
274
- && !p . span . from_expansion ( )
274
+ && !bound . span . from_expansion ( )
275
275
&& let bounds = p
276
276
. bounds
277
277
. iter ( )
@@ -295,7 +295,7 @@ impl TraitBounds {
295
295
span_lint_and_help (
296
296
cx,
297
297
TYPE_REPETITION_IN_BOUNDS ,
298
- p . span ,
298
+ bound . span ,
299
299
"this type has already been used as a bound predicate" ,
300
300
None ,
301
301
hint_string,
@@ -322,8 +322,8 @@ fn check_trait_bound_duplication<'tcx>(cx: &LateContext<'tcx>, generics: &'_ Gen
322
322
. predicates
323
323
. iter ( )
324
324
. filter_map ( |pred| {
325
- if pred. in_where_clause ( )
326
- && let WherePredicate :: BoundPredicate ( bound_predicate) = pred
325
+ if pred. kind . in_where_clause ( )
326
+ && let WherePredicateKind :: BoundPredicate ( bound_predicate) = pred. kind
327
327
&& let TyKind :: Path ( QPath :: Resolved ( _, path) ) = bound_predicate. bounded_ty . kind
328
328
{
329
329
return Some (
@@ -347,10 +347,10 @@ fn check_trait_bound_duplication<'tcx>(cx: &LateContext<'tcx>, generics: &'_ Gen
347
347
// |
348
348
// compare trait bounds keyed by generic name and comparable trait to collected where
349
349
// predicates eg. (T, Clone)
350
- for predicate in generics. predicates . iter ( ) . filter ( |pred| !pred. in_where_clause ( ) ) {
351
- if let WherePredicate :: BoundPredicate ( bound_predicate) = predicate
350
+ for predicate in generics. predicates . iter ( ) . filter ( |pred| !pred. kind . in_where_clause ( ) ) {
351
+ if let WherePredicateKind :: BoundPredicate ( bound_predicate) = predicate. kind
352
352
&& bound_predicate. origin != PredicateOrigin :: ImplTrait
353
- && !bound_predicate . span . from_expansion ( )
353
+ && !predicate . span . from_expansion ( )
354
354
&& let TyKind :: Path ( QPath :: Resolved ( _, path) ) = bound_predicate. bounded_ty . kind
355
355
{
356
356
let traits = rollup_traits ( cx, bound_predicate. bounds , "these bounds contain repeated elements" ) ;
0 commit comments