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

Wrong explicit lifetime annotation elimination advice #10833

Open
ledyba opened this issue Sep 1, 2023 · 0 comments
Open

Wrong explicit lifetime annotation elimination advice #10833

ledyba opened this issue Sep 1, 2023 · 0 comments

Comments

@ledyba
Copy link

ledyba commented Sep 1, 2023

Environment

  • IntelliJ Rust plugin version: 0.4.200.5421-232
  • Rust toolchain version: 1.72.0 (5680fa18f 2023-08-23) x86_64-pc-windows-msvc
  • IDE name and version: CLion 2023.2.1 (CL-232.9559.58)
  • Operating system: Windows 10.0
  • Macro expansion: enabled
  • Additional experimental features: org.rust.macros.proc.attr

Problem description

IntelliJ Rust advies me that this life-time can be elided:

image

But if elided, there occurs syntax error (elimination is not enough)

image

... And if I removed ''a' by my hand, rust compiler says it can't compile the source!

image

Additional note: Rust-analyzer does not say about this elimination.

Here is a (maybe) correct and fully-annotated lifetime annotation:

  pub fn find<'a, 'b, F, R>(&'a self, f: F) -> Option<R>
    where
      F: Fn(&'b String) -> Option<R>,
      'a: 'b
  {
    for entry in &self.entries {
      let r = f(entry);
      if r.is_some() {
        return r;
      }
    }
    None
  }

Steps to reproduce

Please clone this repository:

https://github.com/ledyba/__bug__intellij-rust_lifetime

Here is a main.rs:

https://github.com/ledyba/__bug__intellij-rust_lifetime/blob/magistra/src/main.rs

@ledyba ledyba changed the title Wrong expliciet lifetime annotation elimination advice Wrong explicit lifetime annotation elimination advice Sep 1, 2023
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

1 participant