Add external macros specific diagnostics for check-cfg by Urgau · Pull Request #133221 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation7 Commits3 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

Urgau

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

@jieyouxu

jieyouxu

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),

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?

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

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

@bors

📌 Commit e2fbeec has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors 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

@bors

…iaskrgr

Rollup of 6 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Dec 14, 2024

@bors

…iaskrgr

Rollup of 6 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Dec 14, 2024

@rust-timer

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

@Urgau Urgau mentioned this pull request

Dec 15, 2024

jieyouxu added a commit to jieyouxu/rust that referenced this pull request

Dec 15, 2024

@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

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Dec 15, 2024

@rust-timer

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

Labels

L-unexpected_cfgs

Lint: unexpected_cfgs

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.