diff options
| author | bors <bors@rust-lang.org> | 2023-01-12 17:36:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-01-12 17:36:00 +0000 |
| commit | f9ca9d4112f021fd73258e13ec9e353738ba0482 (patch) | |
| tree | 1aa029d8f2d3f6bac6524de25f77c1f877f4e5b9 | |
| parent | decaba97cc0e682a7b44b3f06f10ad1a8ebe9cba (diff) | |
| parent | fe007179ec3560f86bd15686d60372f8307ca225 (diff) | |
| download | rust-f9ca9d4112f021fd73258e13ec9e353738ba0482.tar.gz rust-f9ca9d4112f021fd73258e13ec9e353738ba0482.zip | |
Auto merge of #10149 - jyn514:duplicate-sysroot, r=flip1995
Don't pass `--sysroot` twice if SYSROOT is set This is useful for rust-lang/rust to allow setting a sysroot that's *only* for build scripts, different from the regular sysroot passed in RUSTFLAGS (since cargo doesn't apply RUSTFLAGS to build scripts or proc-macros). That said, the exact motivation is not particularly important: this fixes a regression from https://github.com/rust-lang/rust-clippy/pull/9881/commits/5907e9155ed7f1312d108aa2110853472da3b029#r1060215684. Note that only RUSTFLAGS is tested in the new integration test; passing --sysroot through `clippy-driver` never worked as far as I can tell, and no one is using it, so I didn't fix it here. Helps with https://github.com/rust-lang/rust/pull/106394. --- changelog: other: `SYSROOT` and `--sysroot` can now be set at the same time [#10149](https://github.com/rust-lang/rust-clippy/pull/10149) <!-- changelog_checked -->
| -rw-r--r-- | .github/driver.sh | 7 | ||||
| -rw-r--r-- | src/driver.rs | 5 | ||||
| -rw-r--r-- | tests/integration.rs | 9 |
3 files changed, 20 insertions, 1 deletions
diff --git a/.github/driver.sh b/.github/driver.sh index 6ff189fc859..798782340ee 100644 --- a/.github/driver.sh +++ b/.github/driver.sh @@ -17,6 +17,13 @@ test "$sysroot" = $desired_sysroot sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) test "$sysroot" = $desired_sysroot +# Check that the --sysroot argument is only passed once (SYSROOT is ignored) +( + cd rustc_tools_util + touch src/lib.rs + SYSROOT=/tmp RUSTFLAGS="--sysroot=$(rustc --print sysroot)" ../target/debug/cargo-clippy clippy --verbose +) + # Make sure this isn't set - clippy-driver should cope without it unset CARGO_MANIFEST_DIR diff --git a/src/driver.rs b/src/driver.rs index bcc096c570e..d521e8d8839 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -256,11 +256,14 @@ pub fn main() { LazyLock::force(&ICE_HOOK); exit(rustc_driver::catch_with_exit_code(move || { let mut orig_args: Vec<String> = env::args().collect(); + let has_sysroot_arg = arg_value(&orig_args, "--sysroot", |_| true).is_some(); let sys_root_env = std::env::var("SYSROOT").ok(); let pass_sysroot_env_if_given = |args: &mut Vec<String>, sys_root_env| { if let Some(sys_root) = sys_root_env { - args.extend(vec!["--sysroot".into(), sys_root]); + if !has_sysroot_arg { + args.extend(vec!["--sysroot".into(), sys_root]); + } }; }; diff --git a/tests/integration.rs b/tests/integration.rs index 818ff70b33f..a771d8b87c8 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,3 +1,12 @@ +//! This test is meant to only be run in CI. To run it locally use: +//! +//! `env INTEGRATION=rust-lang/log cargo test --test integration --features=integration` +//! +//! You can use a different `INTEGRATION` value to test different repositories. +//! +//! This test will clone the specified repository and run Clippy on it. The test succeeds, if +//! Clippy doesn't produce an ICE. Lint warnings are ignored by this test. + #![cfg(feature = "integration")] #![cfg_attr(feature = "deny-warnings", deny(warnings))] #![warn(rust_2018_idioms, unused_lifetimes)] |
