Skip to content

Invalid syntax suggested when missing lifetime coincides with const generic #87853

@lukaslueg

Description

@lukaslueg
struct Foo<const BAR: usize> {
    foobar: &i32
}

On nightly 2021-08-06 the compiler suggests

help: consider introducing a named lifetime parameter
  |
1 | struct Foo<const 'a, BAR: usize> {
2 |     foobar: &'a i32
  |

The const 'a, BAR: usize has the 'a inserted at the wrong place. It should be

help: consider introducing a named lifetime parameter
  |
1 | struct Foo<'a, const BAR: usize> {
2 |     foobar: &'a i32
  |

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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