-
Notifications
You must be signed in to change notification settings - Fork 69
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --print=check-cfg #743
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. Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:
Concerns can be lifted with:
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 |
Add `--print=check-cfg` to get the expected configs This PR adds a new `--print` variant `check-cfg` to get the expected configs. Details and rational can be found on the MCP: rust-lang/compiler-team#743 `@rustbot` label +F-check-cfg +S-waiting-on-MCP r? `@petrochenkov`
Add `--print=check-cfg` to get the expected configs This PR adds a new `--print` variant `check-cfg` to get the expected configs. Details and rational can be found on the MCP: rust-lang/compiler-team#743 ``@rustbot`` label +F-check-cfg +S-waiting-on-MCP r? ``@petrochenkov``
Rollup merge of rust-lang#124320 - Urgau:print-check-cfg, r=petrochenkov Add `--print=check-cfg` to get the expected configs This PR adds a new `--print` variant `check-cfg` to get the expected configs. Details and rational can be found on the MCP: rust-lang/compiler-team#743 ``@rustbot`` label +F-check-cfg +S-waiting-on-MCP r? ``@petrochenkov``
Add `--print=check-cfg` to get the expected configs This PR adds a new `--print` variant `check-cfg` to get the expected configs. Details and rational can be found on the MCP: rust-lang/compiler-team#743 ``@rustbot`` label +F-check-cfg +S-waiting-on-MCP r? ``@petrochenkov``
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.
The text was updated successfully, but these errors were encountered: