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

missing_panics_doc triggers on debug_assert #6739

Closed
lopopolo opened this issue Feb 13, 2021 · 1 comment
Closed

missing_panics_doc triggers on debug_assert #6739

lopopolo opened this issue Feb 13, 2021 · 1 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

Comments

@lopopolo
Copy link

lopopolo commented Feb 13, 2021

Lint name:

I tried this code:

#[inline]
fn temper(mut x: u32) -> u32 {
    x ^= x >> 11;
    x ^= (x << 7) & 0x9d2c_5680;
    x ^= (x << 15) & 0xefc6_0000;
    x ^= x >> 18;
    x
}

impl Mt19937GenRand32 {
    pub fn next_u32(&mut self) -> u32 {
        // Failing this check indicates that, somehow, the structure
        // was not initialized.
        debug_assert!(self.idx != 0);
        if self.idx >= N {
            fill_next_state(self);
        }
        let Wrapping(x) = self.state[self.idx];
        self.idx += 1;
        temper(x)
    }
}

I expected to see this happen: no lint

Instead, this happened:

error: docs for function which may panic missing `# Panics` section
   --> src/mt.rs:271:5
    |
271 | /     pub fn next_u32(&mut self) -> u32 {
272 | |         // Failing this check indicates that, somehow, the structure
273 | |         // was not initialized.
274 | |         debug_assert!(self.idx != 0);
...   |
280 | |         temper(x)
281 | |     }
    | |_____^
    |
note: the lint level is defined here
   --> src/lib.rs:13:9
    |
13  | #![deny(clippy::pedantic)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[deny(clippy::missing_panics_doc)]` implied by `#[deny(clippy::pedantic)]`
note: first possible panic found here
   --> src/mt.rs:274:9
    |
274 |         debug_assert!(self.idx != 0);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Meta

  • cargo clippy -V: clippy 0.1.52 (e9920ef 2021-02-11)
  • rustc -Vv:
    rustc 1.52.0-nightly (e9920ef77 2021-02-11)
    binary: rustc
    commit-hash: e9920ef7749d11fc71cc32ca4ba055bcfeaab945
    commit-date: 2021-02-11
    host: x86_64-unknown-linux-gnu
    release: 1.52.0-nightly
    LLVM version: 11.0.1
    
@lopopolo lopopolo 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 Feb 13, 2021
@lopopolo
Copy link
Author

oops this comes from the indexing operation. sorry for the noise.

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

No branches or pull requests

1 participant