-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Declare a new lint to properly deny warnings in rustdoc #79816
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
r? @jyn514 |
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.
This looks about like what I imagined, thanks :)
|
||
diag | ||
// NOTE(poliorcetics): is 'item' always local here ? Or will this panic one day ? | ||
let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local()); |
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.
It is not always local (e.g. if this is a re-export), I think we found why it wasn't a lint before. Fortunately, we don't need to check the syntax of other crates, so you can just return without doing anything if it's non-local.
See #77230 for more discussion; it would also be good to add a test, since if the behavior changes it should be intentional.
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 the behavior?
@rustbot label +S-waiting-on-review -S-waiting-on-author |
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.
Thanks, LGTM. Can you squash the commits before merging?
Also you need to update
|
7158e11
to
d271e41
Compare
Added the changes you proposed and squashed the whole thing Edit: I forgot to ran |
d271e41
to
0e0ae47
Compare
@bors r+ Looks great, thanks! |
📌 Commit 0e0ae47 has been approved by |
…r=jyn514 Declare a new lint to properly deny warnings in rustdoc This declares a new lint: `INVALID_RUST_CODEBLOCK` that is used by `rustdoc` to properly follow `-D warnings` instead of unconditionally emitting a warning. ## Todo List - [x] Declare lint. - [x] Document lint (file: `src/doc/rustdoc/src/lints.md`). - [x] Use lint in `rustdoc` (file: `src/librustdoc/passes/check_code_block_syntax.rs`, maybe others). - [x] Write tests. - [x] Note: one for the behaviour of the new lint when the error is in a dependency, not the crate being tested (rust-lang#79816 (comment)) - [x] Refactor things. ## Questions - How/where are lints tested ? - Where are lints for `rustdoc` tested ? Fix rust-lang#79792. `@rustbot` label T-rustdoc A-lint
…r=jyn514 Declare a new lint to properly deny warnings in rustdoc This declares a new lint: `INVALID_RUST_CODEBLOCK` that is used by `rustdoc` to properly follow `-D warnings` instead of unconditionally emitting a warning. ## Todo List - [x] Declare lint. - [x] Document lint (file: `src/doc/rustdoc/src/lints.md`). - [x] Use lint in `rustdoc` (file: `src/librustdoc/passes/check_code_block_syntax.rs`, maybe others). - [x] Write tests. - [x] Note: one for the behaviour of the new lint when the error is in a dependency, not the crate being tested (rust-lang#79816 (comment)) - [x] Refactor things. ## Questions - How/where are lints tested ? - Where are lints for `rustdoc` tested ? Fix rust-lang#79792. ``@rustbot`` label T-rustdoc A-lint
2c33488
to
c067fae
Compare
@rustbot label: +S-waiting-on-review -S-waiting-on-author |
This comment has been minimized.
This comment has been minimized.
This adds a new lint to `rustc` that is used in rustdoc when a code block is empty or cannot be parsed as valid Rust code. Previously this was unconditionally a warning. As such some documentation comments were (unknowingly) abusing this to pass despite the `-Dwarnings` used when compiling `rustc`, this should not be the case anymore.
c067fae
to
4f4b2f5
Compare
This is still not correct. Any new lints should be added to |
@@ -7,6 +7,7 @@ LL | | /// \__________pkt->size___________/ \_result->size_/ \__pkt->si | |||
LL | | /// ``` | |||
| |_______^ | |||
| | |||
= note: `#[warn(invalid_rust_codeblock)]` on by default |
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 some tests for when ignore
is present (and for all the rest of the branching you have for the diagnostics)?
@poliorcetics - Ping from triage: can you please resolve the merge conflict and set it to |
Hi @poliorcetics, any updates on this? It's really close to being done :/ |
I'm going to close this - feel free to re-open if you have time to work on this again. |
…pider rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`) Fixes rust-lang#79792. This already went through FCP in rust-lang#79816, so it only needs final review. This is mostly a rebase of rust-lang#79816 - thank you `@poliorcetics` for doing most of the work!
…pider rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`) Fixes rust-lang#79792. This already went through FCP in rust-lang#79816, so it only needs final review. This is mostly a rebase of rust-lang#79816 - thank you ``@poliorcetics`` for doing most of the work!
…pider rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`) Fixes rust-lang#79792. This already went through FCP in rust-lang#79816, so it only needs final review. This is mostly a rebase of rust-lang#79816 - thank you `@poliorcetics` for doing most of the work!
…pider rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`) Fixes rust-lang#79792. This already went through FCP in rust-lang#79816, so it only needs final review. This is mostly a rebase of rust-lang#79816 - thank you ``@poliorcetics`` for doing most of the work!
This declares a new lint:
INVALID_RUST_CODEBLOCK
that is used byrustdoc
to properly follow-D warnings
instead of unconditionally emitting a warning.Todo List
Declare lint.
Document lint (file:
src/doc/rustdoc/src/lints.md
).Use lint in
rustdoc
(file:src/librustdoc/passes/check_code_block_syntax.rs
, maybe others).Write tests.
Refactor things.
Wait on Make rustdoc lints a tool lint instead of built-in #80527.
Fix #79792.
@rustbot label T-rustdoc A-lint