Closed Urgau closed 6 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
@rustbot second
@rustbot label -final-comment-period +major-change-accepted
Proposal
The
--check-cfg
flag allowsrustc
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:
--cfg
flags, which we ignore (for now) becauseRUSTFLAGS
applies to all cratesCargo.toml
with conditional keysThe 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):cfg(windows)
:windows
cfg(feature, values("foo", "bar"))
:feature="foo"
andfeature="bar"
cfg(feature, values(none(), ""))
:feature
andfeature=""
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 merge
on 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.