-
Notifications
You must be signed in to change notification settings - Fork 74
Add --print=check-cfg #743
Copy link
Copy link
Closed
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was acceptedA major change proposal that was accepted
Metadata
Metadata
Assignees
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was acceptedA major change proposal that was accepted
Type
Fields
Give feedbackNo fields configured for issues without a type.
Proposal
The
--check-cfgflag allowsrustcto 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:
--cfgflags, which we ignore (for now) becauseRUSTFLAGSapplies to all cratesCargo.tomlwith conditional keysThe way Cargo checks if the
windowscfg is enabled is by using the--print=cfgflag, 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=cfgby 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):cfg(windows):windowscfg(feature, values("foo", "bar")):feature="foo"andfeature="bar"cfg(feature, values(none(), "")):featureandfeature=""cfg(feature, values(any())):feature=any()cfg(any()):any()any()=any()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:
@rustbot second.-C flag, then full team check-off is required.@rfcbot fcp mergeon either the MCP or the PR.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.