Skip to content

use_self lint misidentifies Self simplification #6221

Closed
@nipunG314

Description

@nipunG314

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions