Uh oh!
There was an error while loading. Please reload this page.
Implement --check-cfg option (RFC 3013) - #89346
Conversation
rust-highfive
commented
Sep 29, 2021
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jyn514
commented
Sep 29, 2021
It would be useful, I think, it catches issues like The code lives around Line 222 in 6f608ce |
Aaron1011
commented
Sep 29, 2021
You can use rust/compiler/rustc_codegen_ssa/src/back/link.rs Line 2445 in 50f9f78 you could either avoid linting, or continue to use |
petrochenkov
commented
Sep 29, 2021
+1 |
mwkmwkmwk
commented
Sep 30, 2021
This option doesn't affect expansion at all, though — the only effect is that lints are emitted. I also don't see why we need specifically rustdoc to catch
Wait, this seems like rustdoc specifically disables all lints except for this short list? Are the "unknown condition" lints somehow special enough to warrant adding here? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Oct 4, 2021
Could you add one more non-error test as well - making sure that |
sivadeilra
commented
Oct 4, 2021
I actually implemented this, last year, when I wrote the RFC. Let me dust off this old branch and see if there's anything worth rescuing from it... |
sivadeilra
commented
Oct 5, 2021
Btw, you're welcome to grab anything useful from my old branch: https://github.com/sivadeilra/rust/tree/user/ardavis/check_cfg If you do, just credit me. I had it mostly working, but had to set it down for some other work. By the time I returned to this work, |
bors
commented
Oct 7, 2021
☔ The latest upstream changes (presumably #89629) made this pull request unmergeable. Please resolve the merge conflicts. |
JohnCSimon
commented
Dec 5, 2021
ping from triage: |
JohnCSimon
commented
Jan 30, 2022
Ping from triage: @rustbot label: +S-inactive |
Implement --check-cfg option (RFC 3013), take 2 This pull-request implement RFC 3013: Checking conditional compilation at compile time (rust-lang/rfcs#3013) and is based on the previous attempt rust-lang#89346 by `@mwkmwkmwk` that was closed due to inactivity. I have address all the review comments from the previous attempt and added some more tests. cc rust-lang#82450 r? `@petrochenkov`
…eGomez Wire up unstable rustc --check-cfg to rustdoc This pull-request wire up the new unstable `--check-cfg` option from `rustc` to `rustdoc` as [requested](rust-lang#93915 (comment)) in the [pull-request](rust-lang#93915) that introduce `--check-cfg`. The motivation was describe in the original PR by `@jyn514` who wrote rust-lang#89346 (comment): > > add plumbing to pass --check-cfg from rustdoc (do we want this one?) > > It would be useful, I think, it catches issues like cfg(doctst) or something (and in general I would like expansion to match rustc as closely as possible).
…eGomez Wire up unstable rustc --check-cfg to rustdoc This pull-request wire up the new unstable `--check-cfg` option from `rustc` to `rustdoc` as [requested](rust-lang#93915 (comment)) in the [pull-request](rust-lang#93915) that introduce `--check-cfg`. The motivation was describe in the original PR by ``@jyn514`` who wrote rust-lang#89346 (comment): > > add plumbing to pass --check-cfg from rustdoc (do we want this one?) > > It would be useful, I think, it catches issues like cfg(doctst) or something (and in general I would like expansion to match rustc as closely as possible).
This is my attempt at implementing rust-lang/rfcs#3013. I'm not quite sure I'm doing this right, so I'd appreciate some feedback.
One major problem I hit in implementation is finding a good node_id to attach the early lint to: neither the config condition itself nor (for
#[cfg]) the item that it guards is suitable, because they won't survive the expansion. For now I've attached the lint to crate root, but this is clearly suboptimal — I think the best we can do is using the parent item'snode_id, but this seems to require a lot of plumbing to get the node_id down to the place where the lint is emitted. Is there some better way to handle this?Also, I haven't implemented the
-Z check-cfgoption specified in the RFC — it seems-Z unstable-optionsalready works as a feature gate well enough, so there's not much point?Other TODOs:
--check-cfgfrom rustdoc (do we want this one?)--check-cfg(or is this something to be done on stabilization?)target_os, ...) — perhaps we can even enable the lint by default for those?cc #82450