Skip to content

Commit

Permalink
Restore where-clause parsing compatibility with rust 1.32
Browse files Browse the repository at this point in the history
Previously:

    error[E0658]: multiple patterns in `if let` and `while let` are unstable (see issue 48215)
        --> src/item.rs:1213:13
         |
    1213 | /             if let WhereClauseLocation::BeforeEq | WhereClauseLocation::Both = where_clause_location
    1214 | |             {
    1215 | |                 generics.where_clause = input.parse()?;
    1216 | |             }
         | |_____________^

    error[E0658]: multiple patterns in `if let` and `while let` are unstable (see issue 48215)
        --> src/item.rs:1225:17
         |
    1225 | /                 if let WhereClauseLocation::AfterEq | WhereClauseLocation::Both =
    1226 | |                     where_clause_location
    1227 | |                 {
    1228 | |                     generics.where_clause = input.parse()?;
    1229 | |                 }
         | |_________________^
  • Loading branch information
dtolnay committed Mar 14, 2022
1 parent 4daa92d commit 7129ca2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,9 +1210,11 @@ pub mod parsing {
}
}

if let WhereClauseLocation::BeforeEq | WhereClauseLocation::Both = where_clause_location
{
generics.where_clause = input.parse()?;
match where_clause_location {
WhereClauseLocation::BeforeEq | WhereClauseLocation::Both => {
generics.where_clause = input.parse()?;
}
_ => {}
}

let ty = if let Some(eq_token) = input.parse()? {
Expand All @@ -1221,12 +1223,13 @@ pub mod parsing {
None
};

if generics.where_clause.is_none() {
if let WhereClauseLocation::AfterEq | WhereClauseLocation::Both =
where_clause_location
match where_clause_location {
WhereClauseLocation::AfterEq | WhereClauseLocation::Both
if generics.where_clause.is_none() =>
{
generics.where_clause = input.parse()?;
}
_ => {}
}

let semi_token: Token![;] = input.parse()?;
Expand Down

0 comments on commit 7129ca2

Please sign in to comment.