Skip to content

Commit 92f61d0

Browse files
committed
Auto merge of #13925 - epage:lint-config, r=weihanglo
[beta-1.79] fix(toml): Don't warn on lints.rust.unexpected_cfgs.check-cfg Beta backports: - #13913 (sort of): removes just the lint warning (in a different way to be minimal) so we reduce warning noise for people using this key on nightly In order to make CI pass, the following PRs are also cherry-picked: - #13865 - #13834 (only `time` due to rust-lang/rust#125319) - #13901 - #13931 - #13920 - #13890 - disable link check (not a cherry pick)
2 parents 8a73841 + 67aa704 commit 92f61d0

File tree

15 files changed

+161
-32
lines changed

15 files changed

+161
-32
lines changed

.github/workflows/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@ jobs:
256256
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
257257
echo `pwd`/mdbook >> $GITHUB_PATH
258258
- run: cd src/doc && mdbook build --dest-dir ../../target/doc
259-
- name: Run linkchecker.sh
260-
run: |
261-
cd target
262-
curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
263-
sh linkcheck.sh --all --path ../src/doc cargo
259+
# - name: Run linkchecker.sh
260+
# run: |
261+
# cd target
262+
# curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
263+
# sh linkcheck.sh --all --path ../src/doc cargo
264264

265265
msrv:
266266
runs-on: ubuntu-latest

Cargo.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ snapbox = { version = "0.5.9", features = ["diff", "path", "term-svg"] }
9595
tar = { version = "0.4.40", default-features = false }
9696
tempfile = "3.10.1"
9797
thiserror = "1.0.58"
98-
time = { version = "0.3", features = ["parsing", "formatting", "serde"] }
98+
time = { version = "0.3.36", features = ["parsing", "formatting", "serde"] }
9999
toml = "0.8.12"
100100
toml_edit = { version = "0.22.11", features = ["serde"] }
101101
tracing = "0.1.40" # be compatible with rustc_log: https://github.com/rust-lang/rust/blob/e51e98dde6a/compiler/rustc_log/Cargo.toml#L9

crates/cargo-test-support/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(clippy::disallowed_methods)]
22

33
fn main() {
4+
println!("cargo:rustc-check-cfg=cfg(emulate_second_only_system)");
45
println!(
56
"cargo:rustc-env=NATIVE_ARCH={}",
67
std::env::var("TARGET").unwrap()

crates/cargo-test-support/containers/apache/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ COPY bar /repos/bar
66
WORKDIR /repos/bar
77
RUN git config --global user.email "[email protected]" &&\
88
git config --global user.name "Test User" &&\
9+
git config --system --add safe.directory '*' &&\
910
git init -b master . &&\
1011
git add Cargo.toml src &&\
1112
git commit -m "Initial commit" &&\
12-
mv .git ../bar.git &&\
13-
cd ../bar.git &&\
14-
git config --bool core.bare true &&\
15-
rm -rf ../bar
13+
cd .. &&\
14+
git clone --bare bar bar.git &&\
15+
rm -rf bar
1616
WORKDIR /
1717

1818
EXPOSE 443

crates/cargo-test-support/containers/sshd/Dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ RUN git config --global user.email "[email protected]" &&\
1717
git init -b master . &&\
1818
git add Cargo.toml src &&\
1919
git commit -m "Initial commit" &&\
20-
mv .git ../bar.git &&\
21-
cd ../bar.git &&\
22-
git config --bool core.bare true &&\
23-
rm -rf ../bar
20+
cd .. &&\
21+
git clone --bare bar bar.git &&\
22+
rm -rf bar
2423
WORKDIR /
2524
USER root
2625

crates/rustfix/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustfix"
3-
version = "0.8.3"
3+
version = "0.8.4"
44
authors = [
55
"Pascal Hertleif <[email protected]>",
66
"Oliver Schneider <[email protected]>",

crates/rustfix/tests/everything/multiple-solutions.fixed.rs renamed to crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::{HashSet};
1+
use std::collections::HashSet;
22

33
fn main() {
44
let _: HashSet<()>;

crates/rustfix/tests/everything/multiple-solutions.json renamed to crates/rustfix/tests/everything/multiple-solutions.nightly.json

+58-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$message_type": "diagnostic",
23
"message": "unused imports: `HashMap`, `VecDeque`",
34
"code": {
45
"code": "unused_imports",
@@ -7,7 +8,7 @@
78
"level": "warning",
89
"spans": [
910
{
10-
"file_name": "src/main.rs",
11+
"file_name": "./tests/everything/multiple-solutions.nightly.rs",
1112
"byte_start": 23,
1213
"byte_end": 30,
1314
"line_start": 1,
@@ -28,7 +29,7 @@
2829
"expansion": null
2930
},
3031
{
31-
"file_name": "src/main.rs",
32+
"file_name": "./tests/everything/multiple-solutions.nightly.rs",
3233
"byte_start": 41,
3334
"byte_end": 49,
3435
"line_start": 1,
@@ -51,7 +52,7 @@
5152
],
5253
"children": [
5354
{
54-
"message": "#[warn(unused_imports)] on by default",
55+
"message": "`#[warn(unused_imports)]` on by default",
5556
"code": null,
5657
"level": "note",
5758
"spans": [],
@@ -64,7 +65,28 @@
6465
"level": "help",
6566
"spans": [
6667
{
67-
"file_name": "src/main.rs",
68+
"file_name": "./tests/everything/multiple-solutions.nightly.rs",
69+
"byte_start": 22,
70+
"byte_end": 23,
71+
"line_start": 1,
72+
"line_end": 1,
73+
"column_start": 23,
74+
"column_end": 24,
75+
"is_primary": true,
76+
"text": [
77+
{
78+
"text": "use std::collections::{HashMap, HashSet, VecDeque};",
79+
"highlight_start": 23,
80+
"highlight_end": 24
81+
}
82+
],
83+
"label": null,
84+
"suggested_replacement": "",
85+
"suggestion_applicability": "MachineApplicable",
86+
"expansion": null
87+
},
88+
{
89+
"file_name": "./tests/everything/multiple-solutions.nightly.rs",
6890
"byte_start": 23,
6991
"byte_end": 32,
7092
"line_start": 1,
@@ -85,7 +107,7 @@
85107
"expansion": null
86108
},
87109
{
88-
"file_name": "src/main.rs",
110+
"file_name": "./tests/everything/multiple-solutions.nightly.rs",
89111
"byte_start": 39,
90112
"byte_end": 49,
91113
"line_start": 1,
@@ -104,11 +126,41 @@
104126
"suggested_replacement": "",
105127
"suggestion_applicability": "MachineApplicable",
106128
"expansion": null
129+
},
130+
{
131+
"file_name": "./tests/everything/multiple-solutions.nightly.rs",
132+
"byte_start": 49,
133+
"byte_end": 50,
134+
"line_start": 1,
135+
"line_end": 1,
136+
"column_start": 50,
137+
"column_end": 51,
138+
"is_primary": true,
139+
"text": [
140+
{
141+
"text": "use std::collections::{HashMap, HashSet, VecDeque};",
142+
"highlight_start": 50,
143+
"highlight_end": 51
144+
}
145+
],
146+
"label": null,
147+
"suggested_replacement": "",
148+
"suggestion_applicability": "MachineApplicable",
149+
"expansion": null
107150
}
108151
],
109152
"children": [],
110153
"rendered": null
111154
}
112155
],
113-
"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"
156+
"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"
157+
}
158+
{
159+
"$message_type": "diagnostic",
160+
"message": "1 warning emitted",
161+
"code": null,
162+
"level": "warning",
163+
"spans": [],
164+
"children": [],
165+
"rendered": "warning: 1 warning emitted\n\n"
114166
}

crates/rustfix/tests/parse_and_replace.rs

+33
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ mod settings {
4545
pub const BLESS: &str = "RUSTFIX_TEST_BLESS";
4646
}
4747

48+
static mut VERSION: (u32, bool) = (0, false);
49+
50+
// Temporarily copy from `cargo_test_macro::version`.
51+
fn version() -> (u32, bool) {
52+
static INIT: std::sync::Once = std::sync::Once::new();
53+
INIT.call_once(|| {
54+
let output = Command::new("rustc")
55+
.arg("-V")
56+
.output()
57+
.expect("cargo should run");
58+
let stdout = std::str::from_utf8(&output.stdout).expect("utf8");
59+
let vers = stdout.split_whitespace().skip(1).next().unwrap();
60+
let is_nightly = option_env!("CARGO_TEST_DISABLE_NIGHTLY").is_none()
61+
&& (vers.contains("-nightly") || vers.contains("-dev"));
62+
let minor = vers.split('.').skip(1).next().unwrap().parse().unwrap();
63+
unsafe { VERSION = (minor, is_nightly) }
64+
});
65+
unsafe { VERSION }
66+
}
67+
4868
fn compile(file: &Path) -> Result<Output, Error> {
4969
let tmp = tempdir()?;
5070

@@ -220,7 +240,20 @@ fn assert_fixtures(dir: &str, mode: &str) {
220240
.unwrap();
221241
let mut failures = 0;
222242

243+
let is_not_nightly = !version().1;
244+
223245
for file in &files {
246+
if file
247+
.file_stem()
248+
.unwrap()
249+
.to_str()
250+
.unwrap()
251+
.ends_with(".nightly")
252+
&& is_not_nightly
253+
{
254+
info!("skipped: {file:?}");
255+
continue;
256+
}
224257
if let Err(err) = test_rustfix_with_file(file, mode) {
225258
println!("failed: {}", file.display());
226259
warn!("{:?}", err);

src/cargo/util/toml/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,11 @@ fn deprecated_underscore<T>(
23562356

23572357
fn warn_on_unused(unused: &BTreeSet<String>, warnings: &mut Vec<String>) {
23582358
for key in unused {
2359+
if key == "lints.rust.unexpected_cfgs.check-cfg" {
2360+
// This key is recognized in the following version and wanting to reduce warning noise
2361+
// for those users
2362+
continue;
2363+
}
23592364
warnings.push(format!("unused manifest key: {}", key));
23602365
if key == "profiles.debug" {
23612366
warnings.push("use `[profile.dev]` to configure debug builds".to_string());

tests/testsuite/bench.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ fn many_similar_names() {
267267
.build();
268268

269269
p.cargo("bench")
270-
.with_stdout_contains("test bin_bench ... bench: 0 ns/iter (+/- 0)")
271-
.with_stdout_contains("test lib_bench ... bench: 0 ns/iter (+/- 0)")
272-
.with_stdout_contains("test bench_bench ... bench: 0 ns/iter (+/- 0)")
270+
.with_stdout_contains("test bin_bench ... bench:[..]")
271+
.with_stdout_contains("test lib_bench ... bench:[..]")
272+
.with_stdout_contains("test bench_bench ... bench:[..]")
273273
.run();
274274
}
275275

tests/testsuite/check_cfg.rs

+28
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,34 @@ fn build_script_feature_gate() {
574574
.run();
575575
}
576576

577+
#[cargo_test]
578+
fn config_simple() {
579+
let p = project()
580+
.file(
581+
"Cargo.toml",
582+
r#"
583+
[package]
584+
name = "foo"
585+
version = "0.1.0"
586+
edition = "2015"
587+
588+
[lints.rust]
589+
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(has_foo)", "cfg(has_bar, values(\"yes\", \"no\"))"] }
590+
"#,
591+
)
592+
.file("src/main.rs", "fn main() {}")
593+
.build();
594+
595+
p.cargo("check")
596+
.with_stderr(
597+
"\
598+
[CHECKING] foo v0.1.0 ([CWD])
599+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
600+
",
601+
)
602+
.run();
603+
}
604+
577605
#[cargo_test(nightly, reason = "--check-cfg is unstable")]
578606
fn config_valid() {
579607
let p = project()

tests/testsuite/standard_lib.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,19 @@ fn setup() -> Setup {
9696
args.push(env::var("REAL_SYSROOT").unwrap());
9797
} else if args.iter().any(|arg| arg == "--target") {
9898
// build-std target unit
99-
args.push("--sysroot".to_string());
100-
args.push("/path/to/nowhere".to_string());
99+
//
100+
// This `--sysroot` is here to disable the sysroot lookup,
101+
// to ensure nothing is required.
102+
// See https://github.com/rust-lang/wg-cargo-std-aware/issues/31
103+
// for more information on this.
104+
//
105+
// FIXME: this is broken on x86_64-unknown-linux-gnu
106+
// due to https://github.com/rust-lang/rust/pull/124129,
107+
// because it requires lld in the sysroot. See
108+
// https://github.com/rust-lang/rust/issues/125246 for
109+
// more information.
110+
// args.push("--sysroot".to_string());
111+
// args.push("/path/to/nowhere".to_string());
101112
} else {
102113
// host unit, do not use sysroot
103114
}

0 commit comments

Comments
 (0)