Skip to content

cargo --config doesn't (seem) to work with lints.* #13018

@kristof-mattei

Description

@kristof-mattei

Problem

I'm trying to set up a separate linting strategy for local development with everything as a warning, but still allow me to compile. Who cares about dead code / unused imports when I'm iterating over a feature? I'll tidy up later.

But on the the CI I want things dialed up to the max.

With the release of lints support in Rust 1.74 I've been trying to get it to work together with --config <PATH> / --config KEY=VALUE, and I've not been successful.

Steps

  1. cargo new lint-config
  2. Put the following in src/main.rs:
    fn main() {
        let vârïàblê = "non-ascii";
    
        println!("Hello, {}!", vârïàblê);
    }
  3. Put the following in ci.toml:
    [lints.rust]
    non_ascii_idents="deny"
  4. Try and build with
    • cargo --config "lints.rust.non_ascii_idents = \"deny\"" build
    • cargo --config lints.rust.non_ascii_idents=\"deny\" build
    • cargo --config "lints.rust.non_ascii_idents='deny'" build
    • cargo --config 'lints.rust.non_ascii_idents="deny"' build
    • cargo --config ci.toml build
      In all situations I've tried forbid instead of deny, and moving build before config.
  5. Notice that in none of the builds we get a failure, even though we expect it to.

Possible Solution(s)

No response

Notes

  1. Moving the lint from ci.toml to Cargo.toml and building with cargo build produces the expected result:
    kristof@NOSTROMO:~/lint-config$ cargo build
       Compiling lint-config v0.1.0 (/home/kristof/lint-config)
    error: identifier contains non-ASCII characters
     --> src/main.rs:2:9
      |
    2 |     let vârïàblê = "non-ascii";
      |         ^^^^^^^^
      |
      = note: requested on the command line with `-D non-ascii-idents`
    
    error: could not compile `lint-config` (bin "lint-config") due to previous error    
  2. Making sure this is supported I tried with cargo --config build.target-dir=\"somewhere-else\" build which changes the target dir & works as expected.

Version

cargo 1.74.0 (ecb9851af 2023-10-18)
release: 1.74.0
commit-hash: ecb9851afd3095e988daaa35a48bc7f3cb748e04
commit-date: 2023-10-18
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.0 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Ubuntu 23.10 (mantic) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions