Skip to content

Incorrect suggestion to add turbofish when > is missing #121901

Closed

Description

@RalfJung

Code

type One = for<'b, 'a> fn(Box<dyn Send + 'a + 'b);

Current output

error: generic args in patterns require the turbofish syntax
 --> src/lib.rs:1:30
  |
1 | type One = for<'b, 'a> fn(Box<dyn Send + 'a + 'b);
  |                              ^
  |
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
  |
1 | type One = for<'b, 'a> fn(Box::<dyn Send + 'a + 'b);
  |                              ++

Desired output

No response

Rationale and extra context

Adding the turbofish is wrong, so the output should be something else that doesn't ask me to add the turbofish.

Other cases

No response

Rust Version

1.76.0 (via Playground), unchanged on current nightly

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 2, 2024
  2. changed the title [-]Incorrect suggestions to add turbofish when `>` is missing[/-] [+]Incorrect suggestion to add turbofish when `>` is missing[/+] on Mar 2, 2024
  3. chenyukang commented on Mar 2, 2024

    @chenyukang
    Member

    If there is an extra >, the compiler is also suggesting add turbofish:

    type One = for<'b, 'a> fn(Box<dyn Send + 'a + 'b>>);

    output:

     --> ./t/test.rs:1:30
      |
    1 | type One = for<'b, 'a> fn(Box<dyn Send + 'a + 'b>>);
      |                              ^
      |
    help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
      |
    1 | type One = for<'b, 'a> fn(Box::<dyn Send + 'a + 'b>>);
      |                              ++
  4. self-assigned this
    on Mar 2, 2024
  5. added
    D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
    D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.
    on Mar 2, 2024
  6. removed their assignment
    on Apr 24, 2024
  7. freyacodes commented on Apr 2, 2025

    @freyacodes
    Contributor

    I am currently working on a PR for these two issues. I already fixed the original part of this issue with no tests failing

    Image

  8. added a commit that references this issue on Apr 2, 2025
    d8d27ca
  9. added 2 commits that reference this issue on Apr 2, 2025
    8277081
    278bc67
  10. added a commit that references this issue on Apr 2, 2025
    bfd6633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions