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

Lifetime elision error not displayed #7053

Closed
branpk opened this issue Dec 27, 2020 · 3 comments
Closed

Lifetime elision error not displayed #7053

branpk opened this issue Dec 27, 2020 · 3 comments

Comments

@branpk
Copy link

branpk commented Dec 27, 2020

fn foo(a: &i32, b: &i32) -> &i32 {}

fn main() {}

rust-analyzer shows no inline errors for the above code. Manually running cargo check works correctly:

error[E0106]: missing lifetime specifier                                                 
 --> src\main.rs:1:29
  |
1 | fn foo(a: &i32, b: &i32) -> &i32 {}
  |           ----     ----     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b`
help: consider introducing a named lifetime parameter
  |
1 | fn foo<'a>(a: &'a i32, b: &'a i32) -> &'a i32 {}
  |       ^^^^    ^^^^^^^     ^^^^^^^     ^^^

but rust-analyzer shows no inline error message.

Other check-on-save errors are shown correctly, so I don't think it's an issue with my setup.

Windows 10, VS Code, Rust 1.50.0 nightly, rust-analyzer v0.2.424

@jonas-schievink
Copy link
Contributor

Please try with a nightly build of r-a

@branpk
Copy link
Author

branpk commented Dec 28, 2020

Thanks!

@branpk branpk closed this as completed Dec 28, 2020
@owtotwo
Copy link

owtotwo commented Aug 23, 2022

I have the same thing.

The reason I speculate is something wrong in cargo's build cache. (Refer: rust-lang/cargo#9971)

Clicking Run button on fn main() {} to force rebuild, and the lifetime error will show correctly temporarily.

But it will be hidden again when the next Check-on-Save.

Development Environment:

  • Windows 10 19044.1889
  • Visual Studio Code 1.70.2
  • rustc 1.63.0 (4b91a6ea7 2022-08-08)
  • rust-analyzer version: 0.3.1178-standalone (a670ff8 2022-08-21)
  • And rust-analyzer version: 0.4.1179-standalone (6711ded 2022-08-22)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants