-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regions
Description
Formerly:
missing lifetime specifier when none is needed
struct B<T>;
impl B< <'a> ||> {}
$ rustc --crate-type=lib foo.rs
foo.rs:3:9: 3:16 error: missing lifetime specifier
foo.rs:3 impl B< <'a> ||> {}
^~~~~~~
error: aborting due to previous error
The type parameter should be a self-contained type, I'm not sure why it's asking for a lifetime specifier.
New description
The error message above seems to be contradictory, since the <'a>
thing is a lifetime itself, however, the problem is the environment of the closure needs a lifetime, which is written like ||:'a
. It would be nice for the error message to guide people towards the correct thing.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regions
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
huonw commentedon May 11, 2014
The
<'a>
is the lifetimes of any parameters, the lifetime of the environment is specified by||:'a
.I'll co-opt this issue for improving the error message, since it's very confusing.
[-]missing lifetime specifier when none is needed[/-][+]Confusing error for missing lifetime on a closure written as `<'a> |...|`[/+]alexcrichton commentedon May 11, 2014
Oops, good point, thanks!
alexcrichton commentedon Feb 2, 2015
Now that closures look a lot more like traits I think that this has basically solved itself.
Include generic arguments when suggesting a closure η-reduction (rust…