Skip to content

use of undeclared lifetime emits incorrect help message #70152

Closed
@lcnr

Description

@lcnr

In case there is an undeclared lifetime in an ADT deriving Eq a wrong help message is emited

#[derive(Eq, PartialEq)]
struct Test {
    a: &'b str,
}

causes the following error

error[E0261]: use of undeclared lifetime name `'b`
 --> src/lib.rs:3:9
  |
2 | struct Test {
  |            - help: consider introducing lifetime `'b` here: `<'b>`
3 |     a: &'b str,
  |         ^^ undeclared lifetime

error[E0261]: use of undeclared lifetime name `'b`
 --> src/lib.rs:3:9
  |
3 |     a: &'b str,
  |         ^^ undeclared lifetime
  |
help: consider introducing lifetime `'b` here
  |
1 | #[derive(<'b>, PartialEq)]
  |          ^^^^
help: consider introducing lifetime `'b` here
  |
1 | #[derive(<'b>, PartialEq)]
  |          ^^^^

thx, bye

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-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