Skip to content

Support for overridable "--cap-lint" and other similar flags in toolchain #3810

@jayzhuang

Description

@jayzhuang

Problem Description

We are looking for a way to enforce a default rustc policy (specifically --cap-lints=deny) at the toolchain level, while retaining the ability to relax this constraint on specific targets (e.g. --cap-lints=allow).

Current Limitation

Currently, rules_rust simply accumulates flags from the toolchain and the target. This works for flags where the last instance overrides previous ones (e.g., -C opt-level), but it fails for rustc flags that behave intersectionally.

Specifically, rustc's --cap-lints uses the "most restrictive" logic. If the toolchain passes deny and the target passes allow, rustc adheres to deny. Because there is no way to prevent the toolchain from emitting its default flags, we are unable to relax the lint cap on a per-target basis.

Proposed Solution / Question

Does rules_rust have plans to support a feature configuration system similar to rules_cc?

In rules_cc, we could define mutually exclusive features (e.g., cap_lints_deny vs cap_lints_allow) where enabling one on a target disables the default. Without this, or a specific "default_rustc_flags" attribute that can be explicitly overridden/cleared by targets, we are forced to use wrapper macros for all targets to manage these defaults.

We would love to see a mechanism to define "weak" defaults in the toolchain that target-level flags can supersede.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions