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

Type specifiers with generic args in certain positions should generate errors that reference the turbofish #114112

Closed
aathan opened this issue Jul 27, 2023 · 3 comments · Fixed by #114300
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST A-patterns Relating to patterns and pattern matching D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. D-papercut Diagnostics: An error or lint that needs small tweaks. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@aathan
Copy link

aathan commented Jul 27, 2023

Code

I'm having trouble creating a concise example, but perhaps the error below is enough. If the error at least mentioned turbofish it'd have saved a bunch of heartache for a noob.

Current output

error: expected one of `)`, `,`, `@`, or `|`, found `<`
   --> ....
    |
143 |             Ok(SomeEnum<STRICT>::SomeVariant { result, .. }) => { ... },
    |                           ^
    |                           |
    |                           expected one of `)`, `,`, `@`, or `|`
    |                           help: missing `,`

Desired output

" if SomeEnum<STRICT> is a type reference, use SomeEnum::<STRICT> instead"

Rationale and extra context

Rust is elsewhere good about suggesting the turbofish.

Other cases

No response

Anything else?

No response

@aathan aathan added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 27, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 27, 2023
@mu001999
Copy link
Contributor

An example (play):

enum E<T> {
    A(T)
}

fn main() {
    match E::A(1) {
        E<i32>::A(v) => {
            println!("{v:?}");
        },
    }
}

@estebank estebank added A-parser Area: The parsing of Rust source code to an AST D-papercut Diagnostics: An error or lint that needs small tweaks. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. A-patterns Relating to patterns and pattern matching and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 28, 2023
@estebank
Copy link
Contributor

To summarize, the parser needs to keep into account a lack of turbofish in patterns. It already does in expressions, and the same strategy can likely be used.

@estebank estebank added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Jul 28, 2023
@mu001999
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 3, 2023
…bank

Suggests turbofish in patterns

Fixes rust-lang#114112

r? `@estebank`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 3, 2023
…bank

Suggests turbofish in patterns

Fixes rust-lang#114112

r? ``@estebank``
@bors bors closed this as completed in 51d1dac Aug 3, 2023
calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Oct 23, 2023
…bank

Suggests turbofish in patterns

Fixes rust-lang#114112

r? ```@estebank```
calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Jun 22, 2024
…bank

Suggests turbofish in patterns

Fixes rust-lang#114112

r? ```@estebank```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST A-patterns Relating to patterns and pattern matching D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. D-papercut Diagnostics: An error or lint that needs small tweaks. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants