From 9d66852a93158502f58389fbcd06a8431b0aee8b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 17 May 2024 12:36:52 -0500 Subject: [PATCH 01/11] test(manifest): Show lint config warning --- tests/testsuite/check_cfg.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/testsuite/check_cfg.rs b/tests/testsuite/check_cfg.rs index 004fc482ad8..dd6bc9670a6 100644 --- a/tests/testsuite/check_cfg.rs +++ b/tests/testsuite/check_cfg.rs @@ -574,6 +574,35 @@ fn build_script_feature_gate() { .run(); } +#[cargo_test] +fn config_simple() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2015" + + [lints.rust] + unexpected_cfgs = { level = "warn", check-cfg = ["cfg(has_foo)", "cfg(has_bar, values(\"yes\", \"no\"))"] } + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("check") + .with_stderr( + "\ +[WARNING] unused manifest key: lints.rust.unexpected_cfgs.check-cfg +[CHECKING] foo v0.1.0 ([CWD]) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s +", + ) + .run(); +} + #[cargo_test(nightly, reason = "--check-cfg is unstable")] fn config_valid() { let p = project() From 8511aab55bf96dd00da9e042a888d203314027d3 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 17 May 2024 12:38:38 -0500 Subject: [PATCH 02/11] fix(toml): Don't warn on lints.rust.unexpected_cfgs.check-cfg While its unused, we thought we'd reduce warning noise for people using this key on nightly. --- src/cargo/util/toml/mod.rs | 5 +++++ tests/testsuite/check_cfg.rs | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 988e34eed27..dae080529ce 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -2356,6 +2356,11 @@ fn deprecated_underscore( fn warn_on_unused(unused: &BTreeSet, warnings: &mut Vec) { for key in unused { + if key == "lints.rust.unexpected_cfgs.check-cfg" { + // This key is recognized in the following version and wanting to reduce warning noise + // for those users + continue; + } warnings.push(format!("unused manifest key: {}", key)); if key == "profiles.debug" { warnings.push("use `[profile.dev]` to configure debug builds".to_string()); diff --git a/tests/testsuite/check_cfg.rs b/tests/testsuite/check_cfg.rs index dd6bc9670a6..08b1e2aff65 100644 --- a/tests/testsuite/check_cfg.rs +++ b/tests/testsuite/check_cfg.rs @@ -595,7 +595,6 @@ fn config_simple() { p.cargo("check") .with_stderr( "\ -[WARNING] unused manifest key: lints.rust.unexpected_cfgs.check-cfg [CHECKING] foo v0.1.0 ([CWD]) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s ", From 1bb52ffd53b7c500e5341f44315d7c3b6ebf481d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 6 May 2024 16:52:29 +0200 Subject: [PATCH 03/11] style(test): Remove check-cfg warning This is currently breaking CI because we run effectively `RUSTDOCFLAGS=-Dwarnings cargo +nightly doc` --- crates/cargo-test-support/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/cargo-test-support/build.rs b/crates/cargo-test-support/build.rs index 8854f461aa6..930666f140e 100644 --- a/crates/cargo-test-support/build.rs +++ b/crates/cargo-test-support/build.rs @@ -1,6 +1,7 @@ #![allow(clippy::disallowed_methods)] fn main() { + println!("cargo:rustc-check-cfg=cfg(emulate_second_only_system)"); println!( "cargo:rustc-env=NATIVE_ARCH={}", std::env::var("TARGET").unwrap() From be111bba6cec381f1c0e2579add42f57a35984a0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 21 May 2024 12:16:07 -0500 Subject: [PATCH 04/11] chore: Update 'time' --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af89b321980..c875e52ad54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3387,9 +3387,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa 1.0.11", @@ -3410,9 +3410,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", diff --git a/Cargo.toml b/Cargo.toml index d55c2bdf7c3..b2b5baf572b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ snapbox = { version = "0.5.9", features = ["diff", "path", "term-svg"] } tar = { version = "0.4.40", default-features = false } tempfile = "3.10.1" thiserror = "1.0.58" -time = { version = "0.3", features = ["parsing", "formatting", "serde"] } +time = { version = "0.3.36", features = ["parsing", "formatting", "serde"] } toml = "0.8.12" toml_edit = { version = "0.22.11", features = ["serde"] } tracing = "0.1.40" # be compatible with rustc_log: https://github.com/rust-lang/rust/blob/e51e98dde6a/compiler/rustc_log/Cargo.toml#L9 From 8cabfab79c33c91c17926e25fed7ff09dcf57f1b Mon Sep 17 00:00:00 2001 From: Greg Morenz Date: Sat, 11 May 2024 00:32:03 -0400 Subject: [PATCH 05/11] Update benchmark formatting for new nightly --- tests/testsuite/bench.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index eb9c92c1edd..85efeaba568 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -267,9 +267,9 @@ fn many_similar_names() { .build(); p.cargo("bench") - .with_stdout_contains("test bin_bench ... bench: 0 ns/iter (+/- 0)") - .with_stdout_contains("test lib_bench ... bench: 0 ns/iter (+/- 0)") - .with_stdout_contains("test bench_bench ... bench: 0 ns/iter (+/- 0)") + .with_stdout_contains("test bin_bench ... bench:[..]") + .with_stdout_contains("test lib_bench ... bench:[..]") + .with_stdout_contains("test bench_bench ... bench:[..]") .run(); } From dde2e1f20f0ddef0644c79c9006f40d95ad489b2 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 18 May 2024 14:00:06 -0700 Subject: [PATCH 06/11] Temporarily fix standard_lib tests on linux. --- tests/testsuite/standard_lib.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/testsuite/standard_lib.rs b/tests/testsuite/standard_lib.rs index d3be303ea8b..82577a57e0b 100644 --- a/tests/testsuite/standard_lib.rs +++ b/tests/testsuite/standard_lib.rs @@ -96,8 +96,19 @@ fn setup() -> Setup { args.push(env::var("REAL_SYSROOT").unwrap()); } else if args.iter().any(|arg| arg == "--target") { // build-std target unit - args.push("--sysroot".to_string()); - args.push("/path/to/nowhere".to_string()); + // + // This `--sysroot` is here to disable the sysroot lookup, + // to ensure nothing is required. + // See https://github.com/rust-lang/wg-cargo-std-aware/issues/31 + // for more information on this. + // + // FIXME: this is broken on x86_64-unknown-linux-gnu + // due to https://github.com/rust-lang/rust/pull/124129, + // because it requires lld in the sysroot. See + // https://github.com/rust-lang/rust/issues/125246 for + // more information. + // args.push("--sysroot".to_string()); + // args.push("/path/to/nowhere".to_string()); } else { // host unit, do not use sysroot } From 1ebfbc5a2098bc0cd4125c3f2b3a2c2c25846ca2 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 15 May 2024 23:40:18 -0400 Subject: [PATCH 07/11] test: set safe.directory for git repo in apache container See https://github.com/git/git/commit/f4aa8c8bb11dae6e769cd930565173808cbb69c8 --- crates/cargo-test-support/containers/apache/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/cargo-test-support/containers/apache/Dockerfile b/crates/cargo-test-support/containers/apache/Dockerfile index 87260241018..2940ee7c6f6 100644 --- a/crates/cargo-test-support/containers/apache/Dockerfile +++ b/crates/cargo-test-support/containers/apache/Dockerfile @@ -6,6 +6,7 @@ COPY bar /repos/bar WORKDIR /repos/bar RUN git config --global user.email "testuser@example.com" &&\ git config --global user.name "Test User" &&\ + git config --system --add safe.directory '*' &&\ git init -b master . &&\ git add Cargo.toml src &&\ git commit -m "Initial commit" &&\ From 088d88887fd214f0bdf7531293afd1610a6abc46 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 15 May 2024 23:43:11 -0400 Subject: [PATCH 08/11] test: use `git clone --bare` instead of manual `mv` --- crates/cargo-test-support/containers/apache/Dockerfile | 7 +++---- crates/cargo-test-support/containers/sshd/Dockerfile | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/cargo-test-support/containers/apache/Dockerfile b/crates/cargo-test-support/containers/apache/Dockerfile index 2940ee7c6f6..926f4c35365 100644 --- a/crates/cargo-test-support/containers/apache/Dockerfile +++ b/crates/cargo-test-support/containers/apache/Dockerfile @@ -10,10 +10,9 @@ RUN git config --global user.email "testuser@example.com" &&\ git init -b master . &&\ git add Cargo.toml src &&\ git commit -m "Initial commit" &&\ - mv .git ../bar.git &&\ - cd ../bar.git &&\ - git config --bool core.bare true &&\ - rm -rf ../bar + cd .. &&\ + git clone --bare bar bar.git &&\ + rm -rf bar WORKDIR / EXPOSE 443 diff --git a/crates/cargo-test-support/containers/sshd/Dockerfile b/crates/cargo-test-support/containers/sshd/Dockerfile index 2c055bbc200..e6187750aee 100644 --- a/crates/cargo-test-support/containers/sshd/Dockerfile +++ b/crates/cargo-test-support/containers/sshd/Dockerfile @@ -17,10 +17,9 @@ RUN git config --global user.email "testuser@example.com" &&\ git init -b master . &&\ git add Cargo.toml src &&\ git commit -m "Initial commit" &&\ - mv .git ../bar.git &&\ - cd ../bar.git &&\ - git config --bool core.bare true &&\ - rm -rf ../bar + cd .. &&\ + git clone --bare bar bar.git &&\ + rm -rf bar WORKDIR / USER root From c99b2e5349aab92f67540f497d75e12c118f7b88 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 22 May 2024 08:55:31 -0500 Subject: [PATCH 09/11] chore(ci): Disable link check It looks like its checking nightly rustc links against cargo which is failing because of links related to check-cfg which is stable on nightly. See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Failures.20on.20Beta.20CI --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e680a32d61f..997911292c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -256,11 +256,11 @@ jobs: curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook echo `pwd`/mdbook >> $GITHUB_PATH - run: cd src/doc && mdbook build --dest-dir ../../target/doc - - name: Run linkchecker.sh - run: | - cd target - curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh - sh linkcheck.sh --all --path ../src/doc cargo +# - name: Run linkchecker.sh +# run: | +# cd target +# curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh +# sh linkcheck.sh --all --path ../src/doc cargo msrv: runs-on: ubuntu-latest From 8bfa91b73d87ead63af05e1c899b10c3f2abc21b Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 9 May 2024 09:08:18 -0400 Subject: [PATCH 10/11] test(rustfix): run some tests only on nightly --- Cargo.lock | 2 +- crates/rustfix/Cargo.toml | 2 +- ...rs => multiple-solutions.nightly.fixed.rs} | 0 ...s.json => multiple-solutions.nightly.json} | 0 ...tions.rs => multiple-solutions.nightly.rs} | 0 crates/rustfix/tests/parse_and_replace.rs | 33 +++++++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) rename crates/rustfix/tests/everything/{multiple-solutions.fixed.rs => multiple-solutions.nightly.fixed.rs} (100%) rename crates/rustfix/tests/everything/{multiple-solutions.json => multiple-solutions.nightly.json} (100%) rename crates/rustfix/tests/everything/{multiple-solutions.rs => multiple-solutions.nightly.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index c875e52ad54..bfa488bfee5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2938,7 +2938,7 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustfix" -version = "0.8.3" +version = "0.8.4" dependencies = [ "anyhow", "proptest", diff --git a/crates/rustfix/Cargo.toml b/crates/rustfix/Cargo.toml index 533d028d95d..1f9b61cd5e2 100644 --- a/crates/rustfix/Cargo.toml +++ b/crates/rustfix/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustfix" -version = "0.8.3" +version = "0.8.4" authors = [ "Pascal Hertleif ", "Oliver Schneider ", diff --git a/crates/rustfix/tests/everything/multiple-solutions.fixed.rs b/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs similarity index 100% rename from crates/rustfix/tests/everything/multiple-solutions.fixed.rs rename to crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs diff --git a/crates/rustfix/tests/everything/multiple-solutions.json b/crates/rustfix/tests/everything/multiple-solutions.nightly.json similarity index 100% rename from crates/rustfix/tests/everything/multiple-solutions.json rename to crates/rustfix/tests/everything/multiple-solutions.nightly.json diff --git a/crates/rustfix/tests/everything/multiple-solutions.rs b/crates/rustfix/tests/everything/multiple-solutions.nightly.rs similarity index 100% rename from crates/rustfix/tests/everything/multiple-solutions.rs rename to crates/rustfix/tests/everything/multiple-solutions.nightly.rs diff --git a/crates/rustfix/tests/parse_and_replace.rs b/crates/rustfix/tests/parse_and_replace.rs index 949903b238f..7bb11d33239 100644 --- a/crates/rustfix/tests/parse_and_replace.rs +++ b/crates/rustfix/tests/parse_and_replace.rs @@ -45,6 +45,26 @@ mod settings { pub const BLESS: &str = "RUSTFIX_TEST_BLESS"; } +static mut VERSION: (u32, bool) = (0, false); + +// Temporarily copy from `cargo_test_macro::version`. +fn version() -> (u32, bool) { + static INIT: std::sync::Once = std::sync::Once::new(); + INIT.call_once(|| { + let output = Command::new("rustc") + .arg("-V") + .output() + .expect("cargo should run"); + let stdout = std::str::from_utf8(&output.stdout).expect("utf8"); + let vers = stdout.split_whitespace().skip(1).next().unwrap(); + let is_nightly = option_env!("CARGO_TEST_DISABLE_NIGHTLY").is_none() + && (vers.contains("-nightly") || vers.contains("-dev")); + let minor = vers.split('.').skip(1).next().unwrap().parse().unwrap(); + unsafe { VERSION = (minor, is_nightly) } + }); + unsafe { VERSION } +} + fn compile(file: &Path) -> Result { let tmp = tempdir()?; @@ -220,7 +240,20 @@ fn assert_fixtures(dir: &str, mode: &str) { .unwrap(); let mut failures = 0; + let is_not_nightly = !version().1; + for file in &files { + if file + .file_stem() + .unwrap() + .to_str() + .unwrap() + .ends_with(".nightly") + && is_not_nightly + { + info!("skipped: {file:?}"); + continue; + } if let Err(err) = test_rustfix_with_file(file, mode) { println!("failed: {}", file.display()); warn!("{:?}", err); From 67aa7042159cfaa8caec0fa94658f7f9b49d1b2c Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 9 May 2024 09:13:01 -0400 Subject: [PATCH 11/11] test(rustfix): bless multiple-solutions.nightly.rs --- .../multiple-solutions.nightly.fixed.rs | 2 +- .../multiple-solutions.nightly.json | 64 +++++++++++++++++-- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs b/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs index 1a261785d77..50ccab26b81 100644 --- a/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs +++ b/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs @@ -1,4 +1,4 @@ -use std::collections::{HashSet}; +use std::collections::HashSet; fn main() { let _: HashSet<()>; diff --git a/crates/rustfix/tests/everything/multiple-solutions.nightly.json b/crates/rustfix/tests/everything/multiple-solutions.nightly.json index 89b14ccc848..ce9d54e4a84 100644 --- a/crates/rustfix/tests/everything/multiple-solutions.nightly.json +++ b/crates/rustfix/tests/everything/multiple-solutions.nightly.json @@ -1,4 +1,5 @@ { + "$message_type": "diagnostic", "message": "unused imports: `HashMap`, `VecDeque`", "code": { "code": "unused_imports", @@ -7,7 +8,7 @@ "level": "warning", "spans": [ { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 23, "byte_end": 30, "line_start": 1, @@ -28,7 +29,7 @@ "expansion": null }, { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 41, "byte_end": 49, "line_start": 1, @@ -51,7 +52,7 @@ ], "children": [ { - "message": "#[warn(unused_imports)] on by default", + "message": "`#[warn(unused_imports)]` on by default", "code": null, "level": "note", "spans": [], @@ -64,7 +65,28 @@ "level": "help", "spans": [ { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", + "byte_start": 22, + "byte_end": 23, + "line_start": 1, + "line_end": 1, + "column_start": 23, + "column_end": 24, + "is_primary": true, + "text": [ + { + "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_start": 23, + "highlight_end": 24 + } + ], + "label": null, + "suggested_replacement": "", + "suggestion_applicability": "MachineApplicable", + "expansion": null + }, + { + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 23, "byte_end": 32, "line_start": 1, @@ -85,7 +107,7 @@ "expansion": null }, { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 39, "byte_end": 49, "line_start": 1, @@ -104,11 +126,41 @@ "suggested_replacement": "", "suggestion_applicability": "MachineApplicable", "expansion": null + }, + { + "file_name": "./tests/everything/multiple-solutions.nightly.rs", + "byte_start": 49, + "byte_end": 50, + "line_start": 1, + "line_end": 1, + "column_start": 50, + "column_end": 51, + "is_primary": true, + "text": [ + { + "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_start": 50, + "highlight_end": 51 + } + ], + "label": null, + "suggested_replacement": "", + "suggestion_applicability": "MachineApplicable", + "expansion": null } ], "children": [], "rendered": null } ], - "rendered": "warning: unused imports: `HashMap`, `VecDeque`\n --> src/main.rs:1:24\n |\n1 | use std::collections::{HashMap, HashSet, VecDeque};\n | ^^^^^^^ ^^^^^^^^\n |\n = note: #[warn(unused_imports)] on by default\nhelp: remove the unused imports\n |\n1 | use std::collections::{HashSet};\n | -- --\n\n" + "rendered": "warning: unused imports: `HashMap`, `VecDeque`\n --> ./tests/everything/multiple-solutions.nightly.rs:1:24\n |\n1 | use std::collections::{HashMap, HashSet, VecDeque};\n | ^^^^^^^ ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\n" +} +{ + "$message_type": "diagnostic", + "message": "1 warning emitted", + "code": null, + "level": "warning", + "spans": [], + "children": [], + "rendered": "warning: 1 warning emitted\n\n" }