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

Elided lifetimes clippy error appeared between 0.1.31 and 0.1.35 #110

Closed
itmecho opened this issue Jun 18, 2020 · 3 comments · Fixed by #111
Closed

Elided lifetimes clippy error appeared between 0.1.31 and 0.1.35 #110

itmecho opened this issue Jun 18, 2020 · 3 comments · Fixed by #111

Comments

@itmecho
Copy link

itmecho commented Jun 18, 2020

I have a Cargo.lock file which has async-trait locked to version 0.1.31 but it's not committed. When I run clippy, I get no error. If I remove that lock file and run clippy again, cargo downloads 0.1.35 and I get an error about needless explicit lifetimes.

Trait

#[async_trait::async_trait]
pub trait Loader {
    async fn load(&self, key: &str) -> Result<String>;
}

Implementation

#[async_trait::async_trait]
impl crate::Loader for AwsEc2MetadataLoader<'_> {
    async fn load(&self, key: &str) -> Result<String> {
        get_metadata_value(self.metadata_url, key).await
    }
}

Clippy error:

$ cargo clippy -- -D warnings
...
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
  --> src/loader/awsec2metadata.rs:58:5
   |
58 |     async fn load(&self, key: &str) -> Result<String> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
...

If I change the method signature in the implementation to the following, the error goes away. From the README, it seems like this shouldn't be necessary?

    async fn load(&self, key: &'_ str) -> Result<String> {
@itmecho
Copy link
Author

itmecho commented Jun 18, 2020

OK, I set the version to =0.1.34 and rerun clippy and the error isn't there so it must be in the latest release.

I have also just updated to rust 1.44.1 but it's still happening so I'm assuming it isn't related to rust-lang/rust-clippy#5356

@dtolnay
Copy link
Owner

dtolnay commented Jun 19, 2020

Thanks! Fixed in 0.1.36.

@itmecho
Copy link
Author

itmecho commented Jun 19, 2020

Thanks for the speedy fix!

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

Successfully merging a pull request may close this issue.

2 participants