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

mixed_attributes_style cannot be disabled globally #12436

Closed
apoelstra opened this issue Mar 8, 2024 · 2 comments · Fixed by #12486
Closed

mixed_attributes_style cannot be disabled globally #12436

apoelstra opened this issue Mar 8, 2024 · 2 comments · Fixed by #12486
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@apoelstra
Copy link

Summary

If the mixed_attributes_style lint is whitelisted in lib.rs/main.rs, but triggered in another file, it still triggers. The top-level whitelist appears to apply only to the top-level file, and inline modules within that file. Not modules which are different files.

Reproducer

I tried this code:

main.rs

#![allow(clippy::mixed_attributes_style)] // https://github.com/rust-lang/rust-clippy/issues/12435
mod submodule;
fn main() {}

submodule.rs

#[cfg(test)]
mod tests {
    //! Doccomment for my tests module
}

The lint triggers:

warning: item has both inner and outer attributes
 --> src/submodule.rs:1:1
  |
1 | / #[cfg(test)]
2 | | mod tests {
3 | |     //! Doccomment for my tests module
  | |______________________________________^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
  = note: `#[warn(clippy::mixed_attributes_style)]` on by default

Version

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2

Additional Labels

No response

@tcharding
Copy link

tcharding commented Mar 11, 2024

Is this similar to #6610?

Possible solution: #6610 (comment)

@J-ZhengLi
Copy link
Member

@tcharding seems like it, at the mean time I'll try moving this to LateLintPass to see if that fix it~

J-ZhengLi added a commit to J-ZhengLi/rust-clippy that referenced this issue Mar 14, 2024
J-ZhengLi added a commit to J-ZhengLi/rust-clippy that referenced this issue Mar 15, 2024
J-ZhengLi added a commit to J-ZhengLi/rust-clippy that referenced this issue Mar 18, 2024
J-ZhengLi added a commit to J-ZhengLi/rust-clippy that referenced this issue Mar 18, 2024
J-ZhengLi added a commit to J-ZhengLi/rust-clippy that referenced this issue Mar 18, 2024
J-ZhengLi added a commit to J-ZhengLi/rust-clippy that referenced this issue Mar 23, 2024
don't lint [`mixed_attributes_style`] when mixing docs and other attrs

add test files for issue rust-lang#12436

move [`mixed_attributes_style`] to `LateLintPass` to enable global `allow`

stop [`mixed_attributes_style`] from linting on different attributes

add `@compile-flags` to [`mixed_attributes_style`]'s test;

turns out not linting in test mod is not a FN.

Apply suggestions from code review

Co-authored-by: Timo <30553356+y21@users.noreply.github.com>

move [`mixed_attributes_style`] to late pass and stop it from linting on different kind of attributes
@bors bors closed this as completed in db41621 Mar 23, 2024
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants