Skip to content
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

Closed
1 of 3 tasks
Urgau opened this issue Apr 23, 2024 · 3 comments
Closed
1 of 3 tasks

Add --print=check-cfg #743

Urgau opened this issue Apr 23, 2024 · 3 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@Urgau
Copy link
Member

Urgau commented Apr 23, 2024

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:

  • --cfg flags, which we ignore (for now) because RUSTFLAGS applies to all crates
  • and in Cargo.toml with conditional keys
    [target.'cfg(windows)'.dependencies]
    libc = "0.2"

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

  • check_cfg syntax: output of --print
  • cfg(windows): windows
  • cfg(feature, values("foo", "bar")): feature="foo" and feature="bar"
  • cfg(feature, values(none(), "")): feature and feature=""
  • cfg(feature, values(any())): feature=any()
  • cfg(any()): any()
  • nothing: 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:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

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.

@Urgau Urgau added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Apr 23, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 23, 2024

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 rustbot added the to-announce Announce this issue on triage meeting label Apr 23, 2024
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label May 3, 2024
@petrochenkov
Copy link

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label May 11, 2024
@apiraino
Copy link
Contributor

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

@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels May 25, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue May 28, 2024
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`
jieyouxu added a commit to jieyouxu/rust that referenced this issue May 29, 2024
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``
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 29, 2024
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``
github-actions bot pushed a commit to rust-lang/miri that referenced this issue May 30, 2024
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``
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants