Skip to content

Suggestion to reorder generic parameters ignores type defaults #80512

Closed
@varkor

Description

@varkor
struct S<T = (), 'a>(&'a T);

results in:

error: lifetime parameters must be declared prior to type parameters
 --> src/lib.rs:1:18
  |
1 | struct S<T = (), 'a>(&'a T);
  |         ---------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T>`

when it should be:

help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = ()>`

This should be easy to fix: just replace ident in the following line with an appropriate format string.

GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident),

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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