Skip to content

Rust adapter: quoted keys and inline tables in .cargo/config bypass the build-config check #221

Closed

Description

@FredApps

changesBuild in src/repo/adapters/rust.ts decides whether a .cargo/config(.toml) changes the build (rustflags, target, [patch], [unstable] and so on). It matches lines with a regex, so it only sees the [build]\nrustflags = … spelling. TOML lets you write the same keys in other ways, and Cargo applies all of them:

config.toml Cargo applies it DiffCI blocks
[build]
rustflags = ["--cfg", "x"]
yes yes
build = { rustflags = ["--cfg", "x"] } yes no
"build".rustflags = ["--cfg", "x"] yes no
[build]
'rustflags' = ['--cfg', 'x']
yes no
unstable = { build-std = ["std"] } yes no
patch = { crates-io = { … } } yes no

I checked the first four with cargo build -v (Cargo 1.100): each passes --cfg x to rustc.

Repro: a single crate with .cargo/config.toml set to build = { rustflags = ["--cfg", "extra"] }. rustAdapter.analyze gives no blocker. Change it to the [build] table form and you get Custom Cargo configuration or compiler environment requires full validation. The same gap applies to $CARGO_HOME/config.toml and to parent directories' configs.

Fix: unquote simple quoted keys before matching, and treat a top-level build, patch or unstable inline table as build-changing. That over-blocks build = { jobs = 4 }, which fails closed and is rare.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions