Skip to content

Add external macros specific diagnostics for check-cfg - #133221

Merged
bors merged 3 commits into
rust-lang:masterfrom
Urgau:check-cfg-macro-diag
Dec 14, 2024
Merged

Add external macros specific diagnostics for check-cfg#133221
bors merged 3 commits into
rust-lang:masterfrom
Urgau:check-cfg-macro-diag

Conversation

@Urgau

@UrgauUrgau commented Nov 19, 2024

Copy link
Copy Markdown
Member

This PR adds specific check-cfg diagnostics for unexpected cfg in external macros.

As well as hiding the some of the Cargo specific help/suggestions as they distraction for external macros and are generally not the right solution.

Follow-up to #132577

@rustbot label +L-unexpected_cfgs
r? compiler

@rustbotrustbot added 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. L-unexpected_cfgs Lint: unexpected_cfgs labels Nov 19, 2024
@jieyouxu

Copy link
Copy Markdown
Member

r? jieyouxu

@jieyouxujieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, the changes LGTM, I have one question

Comment on lines +85 to +86
// FIXME: Get access to a `TyCtxt` from an `EarlyContext`
// crate_name: cx.tcx.crate_name(def_id.krate),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question: is this still problematic?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Answer: yes, crate_name is on tcx, early ctxt doesn't have access to a cstore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is fine.

@jieyouxu

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented Dec 14, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit e2fbeec has been approved by jieyouxu

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 14, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2024
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#133221 (Add external macros specific diagnostics for check-cfg)
- rust-lang#133386 (Update linux_musl base to dynamically link the crt by default)
- rust-lang#134191 (Make some types and methods related to Polonius + Miri public)
- rust-lang#134227 (Update wasi-sdk used to build WASI targets)
- rust-lang#134279 ((Re-)return adjustment target if adjust kind is never-to-any)
- rust-lang#134295 (Encode coroutine-closures in SMIR)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2024
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#133221 (Add external macros specific diagnostics for check-cfg)
- rust-lang#133386 (Update linux_musl base to dynamically link the crt by default)
- rust-lang#134191 (Make some types and methods related to Polonius + Miri public)
- rust-lang#134227 (Update wasi-sdk used to build WASI targets)
- rust-lang#134279 ((Re-)return adjustment target if adjust kind is never-to-any)
- rust-lang#134295 (Encode coroutine-closures in SMIR)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit f96fdab into rust-lang:masterDec 14, 2024
@rustbotrustbot added this to the 1.85.0 milestone Dec 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2024
Rollup merge of rust-lang#133221 - Urgau:check-cfg-macro-diag, r=jieyouxu
Add external macros specific diagnostics for check-cfg
This PR adds specific check-cfg diagnostics for unexpected cfg in external macros.
As well as hiding the some of the Cargo specific help/suggestions as they distraction for external macros and are generally not the right solution.
Follow-up to rust-lang#132577
`@rustbot` label +L-unexpected_cfgs
r? compiler
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Dec 15, 2024
Pass `TyCtxt` to early diagostics decoration
This PR pass a `TyCtxt` to the early diagnostics decoration code so that diagnostics code that take advantage of (a very limited but still useful) `TyCtxt` in their note, help, suggestions, ...
This is particulary useful for rust-lang#133221 which wants to get the crate name of a `DefId`, which is possible with `tcx.crate_name(...)`.
I highly recommend reviewing this PR commit by commit.
r? `@jieyouxu`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 15, 2024
Rollup merge of rust-lang#134339 - Urgau:tcx-in-early-diag, r=jieyouxu
Pass `TyCtxt` to early diagostics decoration
This PR pass a `TyCtxt` to the early diagnostics decoration code so that diagnostics code that take advantage of (a very limited but still useful) `TyCtxt` in their note, help, suggestions, ...
This is particulary useful for rust-lang#133221 which wants to get the crate name of a `DefId`, which is possible with `tcx.crate_name(...)`.
I highly recommend reviewing this PR commit by commit.
r? `@jieyouxu`
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L-unexpected_cfgsLint: unexpected_cfgsS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@Urgau@jieyouxu@bors@compiler-errors@rustbot