Skip to content

Invalid error help of struct generic param with default value #124785

Closed
@A4-Tacks

Description

@A4-Tacks

I tried this code:

struct Foo<T = i32>(&'static T);

I expected to see this happen:

help: consider adding an explicit lifetime bound
  |
1 | struct Foo<T: 'static = i32>(&'static T);
  |             +++++++++

Instead, this happened:

help: consider adding an explicit lifetime bound
  |
1 | struct Foo<T = i32: 'static>(&'static T);
  |                   +++++++++

is syntax error

Meta

(rust playground version):

1.80.0-nightly

(2024-05-05 9c9b568792ef20d8459c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.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