Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix turbofish recovery with multiple generic args #82579

Merged
merged 2 commits into from
Mar 2, 2021

Commits on Feb 27, 2021

  1. Fix turbofish recovery with multiple generic args

    check_mistyped_turbofish_with_multiple_type_params was previously
    expecting type arguments between angle brackets, which is not right, as
    we can also see const expressions. We now use generic argument parser
    instead of type parser.
    
    Test with one, two, and three generic arguments added to check
    consistentcy between
    
    1. check_no_chained_comparison: Called after parsing a nested binop
       application like `x < A > ...` where angle brackets are interpreted as
       binary operators and `A` is an expression.
    
    2. check_mistyped_turbofish_with_multiple_type_params: called by
       `parse_full_stmt` when we expect to see a semicolon after parsing an
       expression but don't see it.
    
       (In `T2<1, 2>::C;`, the expression is `T2 < 1`)
    osa1 committed Feb 27, 2021
    Configuration menu
    Copy the full SHA
    fb631a5 View commit details
    Browse the repository at this point in the history
  2. Recover from X<Y,Z> when parsing const expr

    This adds recovery when in array type syntax user writes
    
        [X; Y<Z, ...>]
    
    instead of
    
        [X; Y::<Z, ...>]
    
    Fixes rust-lang#82566
    
    Note that whenever we parse an expression and know that the next token
    cannot be `,`, we should be calling
    check_mistyped_turbofish_with_multiple_type_params for this recovery.
    Previously we only did this for statement parsing (e.g. `let x = f<a,
    b>;`). We now also do it when parsing the length field in array type
    syntax.
    osa1 committed Feb 27, 2021
    Configuration menu
    Copy the full SHA
    992b914 View commit details
    Browse the repository at this point in the history