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

Avoding the clippy lint with type placeholder _ #7388

Open
pudnax opened this issue Jun 22, 2021 · 0 comments
Open

Avoding the clippy lint with type placeholder _ #7388

pudnax opened this issue Jun 22, 2021 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@pudnax
Copy link

pudnax commented Jun 22, 2021

Lint name:
zero_ptr

I tried this code:

fn dummy_raw_waker() -> RawWaker {
    fn no_op(_: *const ()) {}
    fn clone(_: *const ()) -> RawWaker {
        dummy_raw_waker()
    }
    let vtable = &RawWakerVTable::new(clone, no_op, no_op, no_op);
    RawWaker::new(0 as _, vtable)
}

Clippy is not able to deduce a style lint in cases of implicit cast, but would look at the signature of function RawWaker::new():

pub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker { ... }

Manually placing the type makes clippy recognize the style lint

 RawWaker::new(0 as *const (), vtable)

Meta

  • cargo clippy -V: clippy 0.1.54 (a85f584 2021-06-16)
  • rustc -Vv:
rustc 1.55.0-nightly (a85f584ae 2021-06-16)
binary: rustc
commit-hash: a85f584aebd9b08314bf30b9adc17b4a752143e5
commit-date: 2021-06-16
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1
@pudnax pudnax added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Jun 22, 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-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

1 participant