Skip to content

Misleading error message with unnamed lifetimes #30790

Closed
@Amanieu

Description

@Amanieu

This code results in a horrible error message:

use std::ops::Deref;
trait Trait {}

struct Struct;

impl Deref for Struct {
    type Target = Trait;
    fn deref(&self) -> &Trait {
        unimplemented!();
    }
}
<anon>:8:5: 10:6 error: method `deref` has an incompatible type for trait:
 expected bound lifetime parameter ,
    found concrete lifetime [E0053]
<anon>: 8     fn deref(&self) -> &Trait {
<anon>: 9         unimplemented!();
<anon>:10     }
<anon>:8:5: 10:6 help: see the detailed explanation for E0053

In particular, note the missing lifetime name on the second line of the error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions