-
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
Add new lint doc_include_without_cfg
#13625
Add new lint doc_include_without_cfg
#13625
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very very good PR, just a nit.
I'll open the FCP now, because I'm sure this review cycle will go fast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test for one of the other ways that the #[doc]
attribute can behave?
#![doc(html_playground_url = "https://playground.example.com/")]
And such
d0caf07
to
fbf36cc
Compare
Added code comments and added extra tests. |
@GuillaumeGomez Using macros may trigger false positives (found by looking at the lintcheck diff): macro_rules! tst {
($(#[$attr:meta])*) => {
$(#[$attr])*
fn main() {
println!("Hello, world!");
}
}
}
tst!{
/// This is a test with no included file
} will trigger with:
|
Great catch! If the attribute is generated from a macro, the lint now ignores it. |
18d01ce
to
5111470
Compare
Fixed formatting... |
Great. The new hits in |
afe4556
to
400894d
Compare
They were false positives. So we're forced to check that the snippet is indeed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I had already approved this! ❤️ 🌈
We'll have to wait until the FCP is sorted out, seems that we're having some problems with hover documentation.
"Hover documentation"? I rewrote the lints page recently so maybe it's something I broke. Do you have an issue or a link so I can know what's wrong to fix it by any chance? |
There's not a really way to fix it because it's a Rust Analyzer issue (hover documentation as in when you hover your mouse on the IDE) Here's the FCP: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/FCP.20doc_include_without_cfg |
Ah I see. We can always make it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Could you make it pedantic
?
Sure, done! |
And CI passed. ~o~ |
Oh, and I forgot to mention: Could you also squash those 6 commits? |
5082f34
to
52fe6fd
Compare
52fe6fd
to
404e47a
Compare
Done as well. |
It's becoming more and more common to see people including markdown files in their code using
doc = include_str!("...")
, which is great. However, often there is no condition on this include, which is not great because it slows down compilation and might trigger recompilation if these files are updated.This lint aims at fixing this situation.
changelog: Add new lint
doc_include_without_cfg