@@ -1201,14 +1201,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1201
1201
validate_generic_param_order ( self . dcx ( ) , & generics. params , generics. span ) ;
1202
1202
1203
1203
for predicate in & generics. where_clause . predicates {
1204
- if let WherePredicate :: EqPredicate ( predicate) = predicate {
1205
- deny_equality_constraints ( self , predicate, generics) ;
1204
+ let span = predicate. span ;
1205
+ if let WherePredicateKind :: EqPredicate ( predicate) = & predicate. kind {
1206
+ deny_equality_constraints ( self , predicate, span, generics) ;
1206
1207
}
1207
1208
}
1208
1209
walk_list ! ( self , visit_generic_param, & generics. params) ;
1209
1210
for predicate in & generics. where_clause . predicates {
1210
- match predicate {
1211
- WherePredicate :: BoundPredicate ( bound_pred) => {
1211
+ match & predicate. kind {
1212
+ WherePredicateKind :: BoundPredicate ( bound_pred) => {
1212
1213
// This is slightly complicated. Our representation for poly-trait-refs contains a single
1213
1214
// binder and thus we only allow a single level of quantification. However,
1214
1215
// the syntax of Rust permits quantification in two places in where clauses,
@@ -1511,9 +1512,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1511
1512
fn deny_equality_constraints (
1512
1513
this : & AstValidator < ' _ > ,
1513
1514
predicate : & WhereEqPredicate ,
1515
+ predicate_span : Span ,
1514
1516
generics : & Generics ,
1515
1517
) {
1516
- let mut err = errors:: EqualityInWhere { span : predicate . span , assoc : None , assoc2 : None } ;
1518
+ let mut err = errors:: EqualityInWhere { span : predicate_span , assoc : None , assoc2 : None } ;
1517
1519
1518
1520
// Given `<A as Foo>::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
1519
1521
if let TyKind :: Path ( Some ( qself) , full_path) = & predicate. lhs_ty . kind
@@ -1557,7 +1559,7 @@ fn deny_equality_constraints(
1557
1559
}
1558
1560
}
1559
1561
err. assoc = Some ( errors:: AssociatedSuggestion {
1560
- span : predicate . span ,
1562
+ span : predicate_span ,
1561
1563
ident : * ident,
1562
1564
param : param. ident ,
1563
1565
path : pprust:: path_to_string ( & assoc_path) ,
@@ -1587,23 +1589,23 @@ fn deny_equality_constraints(
1587
1589
// We're removing th eonly where bound left, remove the whole thing.
1588
1590
generics. where_clause . span
1589
1591
} else {
1590
- let mut span = predicate . span ;
1592
+ let mut span = predicate_span ;
1591
1593
let mut prev: Option < Span > = None ;
1592
1594
let mut preds = generics. where_clause . predicates . iter ( ) . peekable ( ) ;
1593
1595
// Find the predicate that shouldn't have been in the where bound list.
1594
1596
while let Some ( pred) = preds. next ( ) {
1595
- if let WherePredicate :: EqPredicate ( pred ) = pred
1596
- && pred. span == predicate . span
1597
+ if let WherePredicateKind :: EqPredicate ( _ ) = pred. kind
1598
+ && pred. span == predicate_span
1597
1599
{
1598
1600
if let Some ( next) = preds. peek ( ) {
1599
1601
// This is the first predicate, remove the trailing comma as well.
1600
- span = span. with_hi ( next. span ( ) . lo ( ) ) ;
1602
+ span = span. with_hi ( next. span . lo ( ) ) ;
1601
1603
} else if let Some ( prev) = prev {
1602
1604
// Remove the previous comma as well.
1603
1605
span = span. with_lo ( prev. hi ( ) ) ;
1604
1606
}
1605
1607
}
1606
- prev = Some ( pred. span ( ) ) ;
1608
+ prev = Some ( pred. span ) ;
1607
1609
}
1608
1610
span
1609
1611
} ;
@@ -1620,8 +1622,8 @@ fn deny_equality_constraints(
1620
1622
if let TyKind :: Path ( None , full_path) = & predicate. lhs_ty . kind {
1621
1623
// Given `A: Foo, Foo::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
1622
1624
for bounds in generics. params . iter ( ) . map ( |p| & p. bounds ) . chain (
1623
- generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match pred {
1624
- WherePredicate :: BoundPredicate ( p) => Some ( & p. bounds ) ,
1625
+ generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match & pred. kind {
1626
+ WherePredicateKind :: BoundPredicate ( p) => Some ( & p. bounds ) ,
1625
1627
_ => None ,
1626
1628
} ) ,
1627
1629
) {
@@ -1644,8 +1646,8 @@ fn deny_equality_constraints(
1644
1646
// Given `A: Foo, A::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
1645
1647
if let [ potential_param, potential_assoc] = & full_path. segments [ ..] {
1646
1648
for ( ident, bounds) in generics. params . iter ( ) . map ( |p| ( p. ident , & p. bounds ) ) . chain (
1647
- generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match pred {
1648
- WherePredicate :: BoundPredicate ( p)
1649
+ generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match & pred. kind {
1650
+ WherePredicateKind :: BoundPredicate ( p)
1649
1651
if let ast:: TyKind :: Path ( None , path) = & p. bounded_ty . kind
1650
1652
&& let [ segment] = & path. segments [ ..] =>
1651
1653
{
0 commit comments