about summary refs log tree commit diff
path: root/src/librustdoc/clean/mod.rs
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-05-27 20:28:30 -0400
committerGitHub <noreply@github.com>2025-05-27 20:28:30 -0400
commit0c2fbe53a69ae8e3b0b779fe5e05aacb0edd7143 (patch)
tree719bafffe8ca267e78c166b692b8772f8d01a6db /src/librustdoc/clean/mod.rs
parent743d2527a26f3d92f82614f303a5b76c28366109 (diff)
parent3fd0265fbb236c8309f2f913cf9946e64818f643 (diff)
downloadrust-0c2fbe53a69ae8e3b0b779fe5e05aacb0edd7143.tar.gz
rust-0c2fbe53a69ae8e3b0b779fe5e05aacb0edd7143.zip
Rollup merge of #140894 - Urgau:check-cfg-rustdoc, r=GuillaumeGomez
Make check-cfg diagnostics work in `#[doc(cfg(..))]`

This PR makes it so that the check-cfg `unexpected_cfgs` lint, is correctly emitted in `rustdoc`'s `#[doc(cfg(..))]`.

This is achieved by adding a custom trait to `cfg_matches` (the method that emits the lint) which permits `rustc` and `rustdoc` to each have their way to emitting lints (via buffered lints/AST for `rustc` and via `TyCtxt`/HIR for `rustdoc`).

The reason this is required is because buffered lints operates on the AST but `rustdoc` uses the HIR and by the time `rustdoc` calls `cfg_matches` we are way passed the point where buffered lints have been drain and emitted.

Best reviewed commit by commit.

r? `@jieyouxu` (for the compiler part)
r? `@GuillaumeGomez` (for the rustdoc part)
Diffstat (limited to 'src/librustdoc/clean/mod.rs')
-rw-r--r--src/librustdoc/clean/mod.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 0fbffc7808d..b7a95384e3f 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -210,6 +210,7 @@ fn generate_item_with_correct_attrs(
             Cow::Owned(attr) => attr,
         }),
         cx.tcx,
+        def_id.as_local().map(|did| cx.tcx.local_def_id_to_hir_id(did)),
         &cx.cache.hidden_cfg,
     );
     let attrs = Attributes::from_hir_iter(attrs.iter().map(|(attr, did)| (&**attr, *did)), false);