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

false positive needless_lifetimes when self is &Arc<Self> #7296

Closed
antialize opened this issue May 31, 2021 · 0 comments · Fixed by #8278
Closed

false positive needless_lifetimes when self is &Arc<Self> #7296

antialize opened this issue May 31, 2021 · 0 comments · Fixed by #8278
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@antialize
Copy link

Lint name: needless_lifetimes

I tried this code:

struct Stuff<'a>(std::marker::PhantomData<&'a ()>);
struct Thing {}
impl Thing {
    fn mut_stuff<'a>(self: &'a std::sync::Arc<Self>) -> Stuff<'a> {todo!()}
}

Clippy complains that <'a> is a needless life time, but it appears to not be the case. None of the following alternatives compile:

fn mut_stuff(self: &std::sync::Arc<Self>) -> Stuff<'_> {todo!()}
fn mut_stuff(self: &'_ std::sync::Arc<Self>) -> Stuff<'_> {todo!()}
fn mut_stuff(self: & std::sync::Arc<Self>) -> Stuff {todo!()}

Meta

Build using the Nightly version: 1.54.0-nightly

(2021-05-30 c1e8f3a)

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=12f0ac7dd5b7f413dffe26a765343475

@antialize antialize added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels May 31, 2021
@bors bors closed this as completed in 1e546c5 Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant