-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
should allow mixing outer cfgs and inner doccomments
#12435
Comments
This might be not as intended @rustbot claim |
IMO this is a more general problem than doc comments. Many attributes have a "preferred" location. A common case is A more general solution would be to only trigger the lint when the same attribute is both outer and inner on an item. |
Yeah, I kind of hate this lint as it doesn't seem consistent with how I use attributes at all. I most definitely have that "this attribute goes here, this attribute goes here" pattern. |
I also noticed this lint when running
|
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 <[email protected]> move [`mixed_attributes_style`] to late pass and stop it from linting on different kind of attributes
Summary
The
mixed_attributes_style
treats doccomments as attributes, which I suppose they technically are, but this is not how users perceive them. It is common with modules to use inner doccomments (and inner style lints, clippy allows, etc., for that matter, but ok, I can accept that the lint doesn't like that) while having outercfg
gates for features.Reproducer
I tried this code:
This triggers the lint:
But I think either fix would be more confusing to read (either add a
#![cfg(test)]
which I have literally never seen in Rust code, or move the doccomment out, which makes it much harder for readers of the code to see that this is a module-level "header comment").Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: