Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“consider using an explicit lifetime parameter” note appears before the corresponding error #15433

Closed
ftxqxd opened this issue Jul 4, 2014 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@ftxqxd
Copy link
Contributor

ftxqxd commented Jul 4, 2014

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.

@bors bors closed this as completed in 7926aee Jul 6, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 21, 2023
…rts, r=lnicola

minor : Deunwrap remove_unused_imports

rust-lang#15398 Subtask 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants