-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This error has an arrow pointing where the lifetime issue is (though I don't know why it isn't more precise):
struct Mine<'a> { s: &'a str }
impl <'a>Iterator<&'a str> for Mine<'a> {
fn next(&mut self) -> Option<&str> { Some("h") }
}
fn main() {}
<anon>:4:5: 4:53 error: method `next` has an incompatible type for trait: expected concrete lifetime, found bound lifetime parameter [E0053]
<anon>:4 fn next(&mut self) -> Option<&str> { Some("h") }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:4:40: 4:53 note: expected concrete lifetime is the lifetime 'a as defined on the block at 4:39
<anon>:4 fn next(&mut self) -> Option<&str> { Some("h") }
^~~~~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101
This won't because next()
is multiline:
struct Mine<'a> { s: &'a str }
impl <'a>Iterator<&'a str> for Mine<'a> {
fn next(&mut self) -> Option<&str> {
Some("h")
}
}
fn main() {}
<anon>:4:5: 6:6 error: method `next` has an incompatible type for trait: expected concrete lifetime, found bound lifetime parameter [E0053]
<anon>:4 fn next(&mut self) -> Option<&str> {
<anon>:5 Some("h")
<anon>:6 }
<anon>:4:40: 6:6 note: expected concrete lifetime is the lifetime 'a as defined on the block at 4:39
<anon>:4 fn next(&mut self) -> Option<&str> {
<anon>:5 Some("h")
<anon>:6 }
error: aborting due to previous error
playpen: application terminated with error code 101
Best would be:
<anon>:4:40: 4:53 note: expected concrete lifetime is the lifetime 'a as defined on the block at 4:39
<anon>:4 fn next(&mut self) -> Option<&str> { Some("h") }
^~~~~~~~~~~~~
Someone might easily put the lifetime on next(&'a self)
instead of Option<&'a str>
because it didn't point and they didn't understand the message.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.