Skip to content

Disallow incoherent cfgs #610

Closed
Closed

Description

@jyn514

Proposal

Disallow combinations of flags that don't make sense. Here is a non-exhaustive list:

  • --cfg debug_assertions -C debug-assertions=off
  • --cfg unix --target x86_64-pc-windows-msvc (and similar for --cfg windows, --cfg target_arch=..., target_os, etc)
  • --cfg test without --test
  • --cfg proc_macro --crate-type lib
  • --cfg panic=abort -C panic=unwind

I don't see any other cfgs in https://doc.rust-lang.org/reference/conditional-compilation.html, but I'm unsure if that's because there are no others or the reference just isn't up to date. The implementation PR should verify that this is an exhaustive list (once all the target_* cfgs are included).

Note that this is technically a breaking change, but in practice any code that is using these combinations of flags is already hopelessly broken. I am of course happy to do a crater run to verify that's true.

Alternatives

Disallow --cfg debug_assertions etc. even if -C debug-assertions=on is set. This seems unnecessary, since the meaning is clear, and would be a larger breaking change.

Mentors or Reviewers

I am not sure who should mentor this work, but the code itself should be fairly simple.

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.

Activity

  1. added
    major-changeA proposal to make a major change to rustc
    T-compilerAdd this label so rfcbot knows to poll the compiler team
    on Apr 6, 2023
  2. rustbot commented on Apr 6, 2023

    @rustbot
    Collaborator

    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.

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

  3. pnkfelix commented on Jun 9, 2023

    @pnkfelix
    Contributor

    @rustbot second

  4. added
    final-comment-periodThe FCP has started, most (if not all) team members are in agreement
    on Jun 9, 2023
  5. apiraino commented on Jul 6, 2023

    @apiraino
    Contributor

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

  6. added
    to-announceAnnounce this issue on triage meeting
    and removed
    final-comment-periodThe FCP has started, most (if not all) team members are in agreement
    on Jul 6, 2023
  7. added a commit that references this issue on Jun 26, 2024
  8. added 5 commits that reference this issue on Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions