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

Conversation

osa1
Copy link
Contributor

@osa1 osa1 commented Feb 27, 2021

This consists of two commits, each can be individually reviewed.


r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2021
@osa1
Copy link
Contributor Author

osa1 commented Feb 27, 2021

It turns out this doesn't really fix #82566 but fixes the issue described in this comment. I'll update this to fix the original issue too.

@rust-log-analyzer

This comment has been minimized.

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`)
@rust-log-analyzer

This comment has been minimized.

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.
@lcnr lcnr added A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints labels Feb 27, 2021
@estebank
Copy link
Contributor

estebank commented Mar 1, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Mar 1, 2021

📌 Commit 992b914 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#80189 (Convert primitives in the standard library to intra-doc links)
 - rust-lang#80874 (Update intra-doc link documentation to match the implementation)
 - rust-lang#82376 (Add option to enable MIR inlining independently of mir-opt-level)
 - rust-lang#82516 (Add incomplete feature gate for inherent associate types.)
 - rust-lang#82579 (Fix turbofish recovery with multiple generic args)
 - rust-lang#82593 (Teach rustdoc how to display WASI.)
 - rust-lang#82597 (Get TyCtxt from self instead of passing as argument in AutoTraitFinder)
 - rust-lang#82627 (Erase late bound regions to avoid ICE)
 - rust-lang#82661 (:arrow_up: rust-analyzer)
 - rust-lang#82691 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 906e535 into rust-lang:master Mar 2, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 2, 2021
@osa1 osa1 deleted the issue82566 branch March 2, 2021 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad diagnostics when using associated const on type without turbofish
7 participants