-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints
Description
fn foo(x: Option<&int>) -> &int {
x.unwrap()
}
fn main() {}Yields the following error:
<anon>:1:1: 3:2 note: consider using an explicit lifetime parameter as shown: fn foo<'a>(x: Option<&'a int>) -> &'a int
<anon>:1 fn foo(x: Option<&int>) -> &int {
<anon>:2 x.unwrap()
<anon>:3 }
<anon>:2:5: 2:15 error: cannot infer an appropriate lifetime due to conflicting requirements
<anon>:2 x.unwrap()
^~~~~~~~~~
<anon>:2:5: 2:15 error: mismatched types: expected `&int` but found `&int` (lifetime mismatch)
<anon>:2 x.unwrap()
^~~~~~~~~~
This could be mildly confusing when there are multiple error messages, and so someone may misinterpret some note as being attached to a previous error. This error should probably appear after the cannot infer an appropriate lifetime error or perhaps after the mismatched types error.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints