Skip to content

Suggest adding undeclared lifetime parameters to struct  #46135

Description

@cramertj

The following code:

struct Foo {
    x: &'a u8,
}

Generates this error:

error[E0261]: use of undeclared lifetime name `'a`
 --> src/main.rs:2:9
  |
2 |     x: &'a u8,
  |         ^^ undeclared lifetime

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

It'd be nice to provide a suggestion to add a lifetime parameter to the struct definition.

Originally suggested here.

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 lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions