Skip to content

Disallow incoherent cfgs #610

Closed
Closed
@jyn514

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.

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