rust-lang / compiler-team

A home for compiler team planning documents, meeting minutes, and other such things.
https://rust-lang.github.io/compiler-team/
Apache License 2.0
387 stars 69 forks source link

Add --print=check-cfg #743

Closed Urgau closed 6 months ago

Urgau commented 7 months ago

Proposal

The --check-cfg flag allows rustc to lint on unexpected cfgs in source code, but source code is not the only place where cfgs appear and are used.

They also appear in:

The way Cargo checks if the windows cfg is enabled is by using the --print=cfg flag, which prints all enabled cfgs, so Cargo only needs to check if the cfg is present in the output or not.

I therefore propose that we (unstably) add the corollary to --print=cfg by adding --print=check-cfg, so that Cargo can then lint over those unexpected cfgs.

This new print option would work similarly to --print=cfg (modulo check-cfg specifics):

Aside from the potential Cargo use, regular users might also want a way to see the list of expected cfgs, either for debugging or verifying things or whatever.

Mentors or Reviewers

@Urgau (for the implementation)

Process

The main points of the Major Change Process are as follows:

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

rustbot commented 7 months ago

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

 @rustbot concern reason-for-concern 
 <description of the concern> 

Concerns can be lifted with:

 @rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler @rust-lang/compiler-contributors

petrochenkov commented 6 months ago

@rustbot second

apiraino commented 6 months ago

@rustbot label -final-comment-period +major-change-accepted