Add docsrs cfg as a well known --check-cfg

This commit is contained in:
Urgau 2024-01-25 14:54:09 +01:00
parent 29386b9c32
commit dfc40a0ca6
2 changed files with 23 additions and 0 deletions

View File

@ -1296,9 +1296,16 @@ fn check_cfg_args(cx: &Context<'_, '_>, unit: &Unit) -> Vec<OsString> {
}
arg_feature.push("))");
// We also include the `docsrs` cfg from the docs.rs service. We include it here
// (in Cargo) instead of rustc, since there is a much closer relationship between
// Cargo and docs.rs than rustc and docs.rs. In particular, all users of docs.rs use
// Cargo, but not all users of rustc (like Rust-for-Linux) use docs.rs.
vec![
OsString::from("-Zunstable-options"),
OsString::from("--check-cfg"),
OsString::from("cfg(docsrs)"),
OsString::from("--check-cfg"),
arg_feature,
]
} else {

View File

@ -50,6 +50,7 @@ fn features() {
p.cargo("check -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -79,6 +80,7 @@ fn features_with_deps() {
p.cargo("check -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -109,6 +111,7 @@ fn features_with_opt_deps() {
p.cargo("check -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "bar" "default" "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -138,6 +141,7 @@ fn features_with_namespaced_features() {
p.cargo("check -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -222,6 +226,7 @@ fn well_known_names_values() {
p.cargo("check -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -246,6 +251,7 @@ fn features_test() {
p.cargo("test -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -272,6 +278,8 @@ fn features_doctest() {
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "default" "f_a" "f_b"))
.with_stderr_contains(x!("rustdoc" => "cfg" of "feature" with "default" "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.with_stderr_contains(x!("rustdoc" => "cfg" of "docsrs"))
.run();
}
@ -285,6 +293,7 @@ fn well_known_names_values_test() {
p.cargo("test -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -299,6 +308,8 @@ fn well_known_names_values_doctest() {
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with))
.with_stderr_contains(x!("rustdoc" => "cfg" of "feature" with))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.with_stderr_contains(x!("rustdoc" => "cfg" of "docsrs"))
.run();
}
@ -324,6 +335,7 @@ fn features_doc() {
p.cargo("doc -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustdoc" => "cfg" of "feature" with "default" "f_a" "f_b"))
.with_stderr_contains(x!("rustdoc" => "cfg" of "docsrs"))
.run();
}
@ -350,6 +362,7 @@ fn build_script_feedback() {
p.cargo("check -v -Zcheck-cfg")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "foo"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}
@ -423,6 +436,8 @@ fn build_script_override() {
p.cargo("check -v -Zcheck-cfg")
.with_stderr_contains(x!("rustc" => "cfg" of "foo"))
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.masquerade_as_nightly_cargo(&["check-cfg"])
.run();
}
@ -573,6 +588,7 @@ fn config_valid() {
p.cargo("check -v")
.masquerade_as_nightly_cargo(&["check-cfg"])
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b"))
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs"))
.run();
}