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

Pin<&mut self> triggers "wrong_self_convention" #4546

Closed
yoshuawuyts opened this issue Sep 16, 2019 · 3 comments · Fixed by #7679
Closed

Pin<&mut self> triggers "wrong_self_convention" #4546

yoshuawuyts opened this issue Sep 16, 2019 · 3 comments · Fixed by #7679
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@yoshuawuyts
Copy link
Member

Clippy doesn't like it when we use Pin over the Self type:

input

pub fn as_mut(self: Pin<&mut Self>) -> Option<&mut Fut::Output>;

output

error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name

  --> src/maybe_done.rs:36:19

   |

36 |     pub fn as_mut(self: Pin<&mut Self>) -> Option<&mut Fut::Output> {

   |                   ^^^^

   |

   = note: `-D clippy::wrong-self-convention` implied by `-D clippy`

   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention

This seems like it might be related to #4037 and #3414. Though it's also possible this may be working exactly as intended, but I'm not sure.

@ghost
Copy link

ghost commented Sep 16, 2019

The lint should probably be changed.

Example from the standard library using similar naming/signature:
https://doc.rust-lang.org/std/option/enum.Option.html#method.as_pin_mut

This is related to issue #4293.

@yoshuawuyts
Copy link
Member Author

Wanted to add that what I was doing here ended up not being a great API either way because it conflicts with the built-in Pin methods.

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Sep 17, 2019
@Darksonn
Copy link

I just ran into this issue.

lengyijun added a commit to lengyijun/rust-clippy that referenced this issue Sep 17, 2021
lengyijun added a commit to lengyijun/rust-clippy that referenced this issue Sep 19, 2021
lengyijun added a commit to lengyijun/rust-clippy that referenced this issue Sep 22, 2021
@bors bors closed this as completed in a4a8ec2 Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants