Skip to content

Commit 36a249b

Browse files
committed
Refer to the Cargo specific doc in the check-cfg diagnostics
1 parent 51ad014 commit 36a249b

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

Diff for: compiler/rustc_lint/src/context/diagnostics/check_cfg.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,12 @@ pub(super) fn unexpected_cfg_name(
172172
diag.help(format!("or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:\n [lints.rust]\n unexpected_cfgs = {{ level = \"warn\", check-cfg = ['{}'] }}", inst(/*with_quotes:*/ false)));
173173
diag.help(format!("or consider adding `println!(\"cargo::rustc-check-cfg={}\");` to the top of the `build.rs`", inst(/*with_quotes:*/ true)));
174174
}
175+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration");
175176
} else {
176177
let inst = inst(/*with_quotes:*/ false);
177178
diag.help(format!("to expect this configuration use `--check-cfg={inst}`",));
179+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
178180
}
179-
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
180181
}
181182

182183
pub(super) fn unexpected_cfg_value(
@@ -271,11 +272,12 @@ pub(super) fn unexpected_cfg_value(
271272
diag.help(format!("or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:\n [lints.rust]\n unexpected_cfgs = {{ level = \"warn\", check-cfg = ['{}'] }}", inst(/*with_quotes:*/ false)));
272273
diag.help(format!("or consider adding `println!(\"cargo::rustc-check-cfg={}\");` to the top of the `build.rs`", inst(/*with_quotes:*/ true)));
273274
}
275+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration");
274276
} else {
275277
if !is_cfg_a_well_know_name {
276278
let inst = inst(/*with_quotes:*/ false);
277279
diag.help(format!("to expect this configuration use `--check-cfg={inst}`",));
278280
}
281+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
279282
}
280-
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
281283
}

Diff for: tests/ui/check-cfg/cargo-feature.none.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(feature = "serde")]
66
|
77
= note: no expected values for `feature`
88
= help: consider adding `serde` as a feature in `Cargo.toml`
9-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value: (none)
@@ -17,7 +17,7 @@ LL | #[cfg(feature)]
1717
|
1818
= note: no expected values for `feature`
1919
= help: consider defining some features in `Cargo.toml`
20-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
20+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
2121

2222
warning: unexpected `cfg` condition name: `tokio_unstable`
2323
--> $DIR/cargo-feature.rs:22:7
@@ -31,7 +31,7 @@ LL | #[cfg(tokio_unstable)]
3131
[lints.rust]
3232
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
3333
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(tokio_unstable)");` to the top of the `build.rs`
34-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
34+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
3535

3636
warning: unexpected `cfg` condition name: `CONFIG_NVME`
3737
--> $DIR/cargo-feature.rs:26:7
@@ -44,7 +44,7 @@ LL | #[cfg(CONFIG_NVME = "m")]
4444
[lints.rust]
4545
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CONFIG_NVME, values("m"))'] }
4646
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of the `build.rs`
47-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
47+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
4848

4949
warning: 4 warnings emitted
5050

Diff for: tests/ui/check-cfg/cargo-feature.some.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(feature = "serde")]
66
|
77
= note: expected values for `feature` are: `bitcode`
88
= help: consider adding `serde` as a feature in `Cargo.toml`
9-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value: (none)
@@ -17,7 +17,7 @@ LL | #[cfg(feature)]
1717
|
1818
= note: expected values for `feature` are: `bitcode`
1919
= help: consider defining some features in `Cargo.toml`
20-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
20+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
2121

2222
warning: unexpected `cfg` condition name: `tokio_unstable`
2323
--> $DIR/cargo-feature.rs:22:7
@@ -31,7 +31,7 @@ LL | #[cfg(tokio_unstable)]
3131
[lints.rust]
3232
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
3333
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(tokio_unstable)");` to the top of the `build.rs`
34-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
34+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
3535

3636
warning: unexpected `cfg` condition value: `m`
3737
--> $DIR/cargo-feature.rs:26:7
@@ -47,7 +47,7 @@ LL | #[cfg(CONFIG_NVME = "m")]
4747
[lints.rust]
4848
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CONFIG_NVME, values("m"))'] }
4949
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of the `build.rs`
50-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
50+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
5151

5252
warning: 4 warnings emitted
5353

Diff for: tests/ui/check-cfg/diagnotics.cargo.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | #[cfg(featur)]
55
| ^^^^^^ help: there is a config with a similar name: `feature`
66
|
77
= help: expected values for `feature` are: `foo`
8-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
8+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
99
= note: `#[warn(unexpected_cfgs)]` on by default
1010

1111
warning: unexpected `cfg` condition name: `featur`
@@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `featur`
1414
LL | #[cfg(featur = "foo")]
1515
| ^^^^^^^^^^^^^^
1616
|
17-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
17+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
1818
help: there is a config with a similar name and value
1919
|
2020
LL | #[cfg(feature = "foo")]
@@ -27,7 +27,7 @@ LL | #[cfg(featur = "fo")]
2727
| ^^^^^^^^^^^^^
2828
|
2929
= help: expected values for `feature` are: `foo`
30-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
30+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
3131
help: there is a config with a similar name and different values
3232
|
3333
LL | #[cfg(feature = "foo")]
@@ -44,7 +44,7 @@ LL | #[cfg(no_value)]
4444
[lints.rust]
4545
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(no_value)'] }
4646
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(no_value)");` to the top of the `build.rs`
47-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
47+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
4848

4949
warning: unexpected `cfg` condition name: `no_value`
5050
--> $DIR/diagnotics.rs:27:7
@@ -57,7 +57,7 @@ LL | #[cfg(no_value = "foo")]
5757
[lints.rust]
5858
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(no_value, values("foo"))'] }
5959
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(no_value, values(\"foo\"))");` to the top of the `build.rs`
60-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
60+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
6161
help: there is a config with a similar name and no value
6262
|
6363
LL | #[cfg(no_values)]
@@ -77,7 +77,7 @@ LL | #[cfg(no_values = "bar")]
7777
[lints.rust]
7878
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(no_values, values("bar"))'] }
7979
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(no_values, values(\"bar\"))");` to the top of the `build.rs`
80-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
80+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
8181

8282
warning: 6 warnings emitted
8383

0 commit comments

Comments
 (0)