Skip to content

Make check-cfg diagnostics work in #[doc(cfg(..))] #140894

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented May 10, 2025

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)

@Urgau Urgau added the F-check-cfg --check-cfg label May 10, 2025
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 10, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler changes seem fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) F-check-cfg --check-cfg S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants