@@ -1200,14 +1200,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1200
1200
validate_generic_param_order ( self . dcx ( ) , & generics. params , generics. span ) ;
1201
1201
1202
1202
for predicate in & generics. where_clause . predicates {
1203
- if let WherePredicate :: EqPredicate ( predicate) = predicate {
1204
- deny_equality_constraints ( self , predicate, generics) ;
1203
+ let span = predicate. span ;
1204
+ if let WherePredicateKind :: EqPredicate ( predicate) = & predicate. kind {
1205
+ deny_equality_constraints ( self , predicate, span, generics) ;
1205
1206
}
1206
1207
}
1207
1208
walk_list ! ( self , visit_generic_param, & generics. params) ;
1208
1209
for predicate in & generics. where_clause . predicates {
1209
- match predicate {
1210
- WherePredicate :: BoundPredicate ( bound_pred) => {
1210
+ match & predicate. kind {
1211
+ WherePredicateKind :: BoundPredicate ( bound_pred) => {
1211
1212
// This is slightly complicated. Our representation for poly-trait-refs contains a single
1212
1213
// binder and thus we only allow a single level of quantification. However,
1213
1214
// the syntax of Rust permits quantification in two places in where clauses,
@@ -1504,9 +1505,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1504
1505
fn deny_equality_constraints (
1505
1506
this : & AstValidator < ' _ > ,
1506
1507
predicate : & WhereEqPredicate ,
1508
+ predicate_span : Span ,
1507
1509
generics : & Generics ,
1508
1510
) {
1509
- let mut err = errors:: EqualityInWhere { span : predicate . span , assoc : None , assoc2 : None } ;
1511
+ let mut err = errors:: EqualityInWhere { span : predicate_span , assoc : None , assoc2 : None } ;
1510
1512
1511
1513
// Given `<A as Foo>::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
1512
1514
if let TyKind :: Path ( Some ( qself) , full_path) = & predicate. lhs_ty . kind
@@ -1550,7 +1552,7 @@ fn deny_equality_constraints(
1550
1552
}
1551
1553
}
1552
1554
err. assoc = Some ( errors:: AssociatedSuggestion {
1553
- span : predicate . span ,
1555
+ span : predicate_span ,
1554
1556
ident : * ident,
1555
1557
param : param. ident ,
1556
1558
path : pprust:: path_to_string ( & assoc_path) ,
@@ -1580,23 +1582,23 @@ fn deny_equality_constraints(
1580
1582
// We're removing th eonly where bound left, remove the whole thing.
1581
1583
generics. where_clause . span
1582
1584
} else {
1583
- let mut span = predicate . span ;
1585
+ let mut span = predicate_span ;
1584
1586
let mut prev: Option < Span > = None ;
1585
1587
let mut preds = generics. where_clause . predicates . iter ( ) . peekable ( ) ;
1586
1588
// Find the predicate that shouldn't have been in the where bound list.
1587
1589
while let Some ( pred) = preds. next ( ) {
1588
- if let WherePredicate :: EqPredicate ( pred ) = pred
1589
- && pred. span == predicate . span
1590
+ if let WherePredicateKind :: EqPredicate ( _ ) = pred. kind
1591
+ && pred. span == predicate_span
1590
1592
{
1591
1593
if let Some ( next) = preds. peek ( ) {
1592
1594
// This is the first predicate, remove the trailing comma as well.
1593
- span = span. with_hi ( next. span ( ) . lo ( ) ) ;
1595
+ span = span. with_hi ( next. span . lo ( ) ) ;
1594
1596
} else if let Some ( prev) = prev {
1595
1597
// Remove the previous comma as well.
1596
1598
span = span. with_lo ( prev. hi ( ) ) ;
1597
1599
}
1598
1600
}
1599
- prev = Some ( pred. span ( ) ) ;
1601
+ prev = Some ( pred. span ) ;
1600
1602
}
1601
1603
span
1602
1604
} ;
@@ -1613,8 +1615,8 @@ fn deny_equality_constraints(
1613
1615
if let TyKind :: Path ( None , full_path) = & predicate. lhs_ty . kind {
1614
1616
// Given `A: Foo, Foo::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
1615
1617
for bounds in generics. params . iter ( ) . map ( |p| & p. bounds ) . chain (
1616
- generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match pred {
1617
- WherePredicate :: BoundPredicate ( p) => Some ( & p. bounds ) ,
1618
+ generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match & pred. kind {
1619
+ WherePredicateKind :: BoundPredicate ( p) => Some ( & p. bounds ) ,
1618
1620
_ => None ,
1619
1621
} ) ,
1620
1622
) {
@@ -1637,8 +1639,8 @@ fn deny_equality_constraints(
1637
1639
// Given `A: Foo, A::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
1638
1640
if let [ potential_param, potential_assoc] = & full_path. segments [ ..] {
1639
1641
for ( ident, bounds) in generics. params . iter ( ) . map ( |p| ( p. ident , & p. bounds ) ) . chain (
1640
- generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match pred {
1641
- WherePredicate :: BoundPredicate ( p)
1642
+ generics. where_clause . predicates . iter ( ) . filter_map ( |pred| match & pred. kind {
1643
+ WherePredicateKind :: BoundPredicate ( p)
1642
1644
if let ast:: TyKind :: Path ( None , path) = & p. bounded_ty . kind
1643
1645
&& let [ segment] = & path. segments [ ..] =>
1644
1646
{
0 commit comments