Skip to content

Workspace inheritance reads from wrong workspace when one is nested inside of another #14645

Open
@heaths

Description

@heaths

Problem

We have a monorepo where we want to manage some lints at the workspace level. We also have some CI scripts that set RUSTFLAGS=-Dwarnings. For crates that set lints.workspace = true, lint configuration is ignored. I've even tried setting the priority as discussed in #12208 et. al. to no avail.

If I simply set e.g., lints.clippy.useless_format = "allow" in the specific crates' Cargo.toml, no warnings-as-errors are emitted.

Steps

  1. Create a workspace Cargo.toml with the content:
    [workspace.lints.clippy]
    useless_format = "allow" # or even { level = "allow", priority = -1 }
  2. Create a crate Cargo.toml with content:
    [lints]
    workspace = true
  3. Add some code to trigger the example lint. In our case, it's generated code where almost all strings will have format specifiers and determining otherwise for a few instances didn't seem worth the cost.
    fn example() -> String {
       format!("/some/path")
    }
  4. Run the following command. Notice that clippy::useless_format warnings-as-errors are still emitted and the command fails.
    # Also tried on 1.74.0, 1.76.0, and nightly to same effect.
    # Stable for the repo is 1.74, but system-wide is 1.81 and still repros.
    RUSTFLAGS=-Dwarnings cargo +stable clippy --workspace
  5. Change step 2 content to:
    [lints.clippy]
    useless_format = "allow"
  6. Rust step 4 command again. Notice no errors are emitted.

Possible Solution(s)

No response

Notes

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-workspace-inheritanceArea: workspace inheritance RFC 2906C-bugCategory: bugS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions