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

use_self lint misidentifies Self simplification #6221

Closed
nipunG314 opened this issue Oct 25, 2020 · 1 comment · Fixed by #6179
Closed

use_self lint misidentifies Self simplification #6221

nipunG314 opened this issue Oct 25, 2020 · 1 comment · Fixed by #6179
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@nipunG314
Copy link

I tried clippy with this code:

pub trait MathExt {
    fn pow(self, factor: Self) -> Self;
    fn sqrt(self) -> Self;
    ...
}

impl MathExt for f32 {
    fn pow(self, factor: Self) -> Self {
        unsafe { core::intrinsics::powf32(self, factor) }
    }
    ...
}

It throws me the following warning:

warning: unnecessary structure name repetition
  --> spirv-std/src/math/mod.rs:34:18
   |
34 |         unsafe { core::intrinsics::powf32(self, factor) }
   |                  ^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
   |
note: the lint level is defined here
  --> spirv-std/src/lib.rs:14:5
   |
14 |     clippy::use_self,
   |     ^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self

However, core::intrinsics cannot be replaced by Self (which is f32 here). Doing so will result in an obvious compile error.

Any idea why this is happening?

Meta

  • cargo clippy -V: clippy 0.0.212 (7bade6e 2020-10-23)
  • rustc -Vv:
rustc 1.49.0-nightly (7bade6ef7 2020-10-23)
binary: rustc
commit-hash: 7bade6ef730cff83f3591479a98916920f66decd
commit-date: 2020-10-23
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0
@nipunG314 nipunG314 added the C-bug Category: Clippy is not doing the correct thing label Oct 25, 2020
@giraffate
Copy link
Contributor

related issue: #4734

@rustbot modify labels: +L-suggestion-causes-error

@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Oct 26, 2020
bors added a commit that referenced this issue Jan 19, 2021
Rework use_self impl based on ty::Ty comparison #3410 | Take 2

This builds on top of #5531

I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary.

I would also appreciate your review `@montrivo,` since you are familiar with the challenges here.

Fixes #3410 and Fixes #4143 (same problem)
Fixes #2843
Fixes #3859
Fixes #4734 and fixes #6221
Fixes #4305
Fixes #5078 (even at expression level now 🎉)
Fixes #3881 and Fixes #4887 (same problem)
Fixes #3909

Not yet: #4140 (test added)

All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code.

changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
bors added a commit that referenced this issue Feb 10, 2021
Rework use_self impl based on ty::Ty comparison #3410 | Take 2

This builds on top of #5531

I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary.

I would also appreciate your review `@montrivo,` since you are familiar with the challenges here.

Fixes #3410 and Fixes #4143 (same problem)
Fixes #2843
Fixes #3859
Fixes #4734 and fixes #6221
Fixes #4305
Fixes #5078 (even at expression level now 🎉)
Fixes #3881 and Fixes #4887 (same problem)
Fixes #3909

Not yet: #4140 (test added)

All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code.

changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
@bors bors closed this as completed in 605e9ba Feb 12, 2021
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-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants