Skip to content

Suggest adding & when a lifetime immediately precedes a type in a generic arg list #59325

Description

@meithecatte

If one types

fn foo(bar: 'static SomeStruct) { ... }

the compiler could suggest adding a & before the lifetime. This can be more useful in a generic parameter, where a high concentration of special characters makes it easy to not notice the mistake:

fn foo(bar: &mut HashSet<'static SomeStruct>) { ... }

Currently, the error message is just expected one of `,` or `>`, found `SomeStruct` .

Activity

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 lintsA-lifetimesArea: Lifetimes / regionsA-parserArea: The lexing & parsing of Rust source code to an ASTD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.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