Skip to content

Duplicate rustflags should be de-duplicated #13774

Open

Description

Problem

I have a crate with a .cargo/config.toml to enable tracing unstable features:

[build]
rustflags = ["--cfg", "tracing_unstable"]

However I use this crate as part of a workspace. So I also put the previous config.toml in my workspace .cargo/config.toml.

Now everytime I save, rust-analyzer build every crate if I did a cargo check in the crate directory.
I found that it's because the rustflags are not merged properly:

INFO cargo::core::compiler::fingerprint:     dirty: RustflagsChanged { old: ["--cfg", "tracing_unstable"], new: ["--cfg", "tracing_unstable", "--cfg", "tracing_unstable"] }

Steps

  1. Create a workspace and put the following content in .cargo/config.toml:
[build]
rustflags = ["--cfg", "tracing_unstable"]
  1. Create a crate foo and put the following content in foo/.cargo/config.toml:
[build]
rustflags = ["--cfg", "tracing_unstable"]
  1. Now cargo check in the workspace and in the foo crate are rebuilding every crate instead of using previously built ones.

Possible Solution(s)

When appending rustflags, check for possible duplicates to avoid multiple same values counting as different ones.

Notes

No response

Version

cargo 1.78.0-nightly (ccc84ccec 2024-02-07)
release: 1.78.0-nightly
commit-hash: ccc84ccec4b7340eb916aefda1cb3e2fe17d8e7b
commit-date: 2024-02-07
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.22621 (Windows 11 Professional) [64-bit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-rustflagsArea: rustflagsArea: rustflagsC-bugCategory: bugCategory: bugE-hardExperience: HardExperience: HardS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions