Auto merge of #137093 - matthiaskrgr:rollup-72j7mut, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #127581 (Fix crate name validation)
 - #136490 (Do not allow attributes on struct field rest patterns)
 - #136808 (Try to recover from path sep error in type parsing)
 - #137055 (rustdoc: Properly restore search input placeholder)
 - #137068 (fix(rustdoc): Fixed `Copy Item Path` in rust doc)
 - #137070 (Do not generate invalid links in job summaries)
 - #137074 (compiletest: add `{ignore,only}-rustc_abi-x86-sse2` directives)
 - #137076 (triagebot.toml: ping me on changes to `tests/rustdoc-json`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-02-16 01:29:09 +00:00
commit 500a686ba8
52 changed files with 411 additions and 209 deletions

View file

@ -517,6 +517,7 @@ pub struct TargetCfgs {
pub all_abis: HashSet<String>,
pub all_families: HashSet<String>,
pub all_pointer_widths: HashSet<String>,
pub all_rustc_abis: HashSet<String>,
}
impl TargetCfgs {
@ -536,6 +537,9 @@ impl TargetCfgs {
let mut all_abis = HashSet::new();
let mut all_families = HashSet::new();
let mut all_pointer_widths = HashSet::new();
// NOTE: for distinction between `abi` and `rustc_abi`, see comment on
// `TargetCfg::rustc_abi`.
let mut all_rustc_abis = HashSet::new();
// If current target is not included in the `--print=all-target-specs-json` output,
// we check whether it is a custom target from the user or a synthetic target from bootstrap.
@ -576,7 +580,9 @@ impl TargetCfgs {
all_families.insert(family.clone());
}
all_pointer_widths.insert(format!("{}bit", cfg.pointer_width));
if let Some(rustc_abi) = &cfg.rustc_abi {
all_rustc_abis.insert(rustc_abi.clone());
}
all_targets.insert(target.clone());
}
@ -590,6 +596,7 @@ impl TargetCfgs {
all_abis,
all_families,
all_pointer_widths,
all_rustc_abis,
}
}
@ -676,6 +683,10 @@ pub struct TargetCfg {
pub(crate) xray: bool,
#[serde(default = "default_reloc_model")]
pub(crate) relocation_model: String,
// NOTE: `rustc_abi` should not be confused with `abi`. `rustc_abi` was introduced in #137037 to
// make SSE2 *required* by the ABI (kind of a hack to make a target feature *required* via the
// target spec).
pub(crate) rustc_abi: Option<String>,
// Not present in target cfg json output, additional derived information.
#[serde(skip)]

View file

@ -87,6 +87,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-remote",
"ignore-riscv64",
"ignore-rustc-debug-assertions",
"ignore-rustc_abi-x86-sse2",
"ignore-s390x",
"ignore-sgx",
"ignore-sparc64",
@ -198,6 +199,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-nvptx64",
"only-powerpc",
"only-riscv64",
"only-rustc_abi-x86-sse2",
"only-s390x",
"only-sparc",
"only-sparc64",

View file

@ -234,6 +234,14 @@ fn parse_cfg_name_directive<'a>(
allowed_names: ["coverage-map", "coverage-run"],
message: "when the test mode is {name}",
}
condition! {
name: target_cfg.rustc_abi.as_ref().map(|abi| format!("rustc_abi-{abi}")).unwrap_or_default(),
allowed_names: ContainsPrefixed {
prefix: "rustc_abi-",
inner: target_cfgs.all_rustc_abis.clone(),
},
message: "when the target `rustc_abi` is {name}",
}
condition! {
name: "dist",

View file

@ -889,3 +889,17 @@ fn test_needs_target_has_atomic() {
assert!(!check_ignore(&config, "//@ needs-target-has-atomic: 8, ptr"));
assert!(check_ignore(&config, "//@ needs-target-has-atomic: 8, ptr, 128"));
}
#[test]
// FIXME: this test will fail against stage 0 until #137037 changes reach beta.
#[cfg_attr(bootstrap, ignore)]
fn test_rustc_abi() {
let config = cfg().target("i686-unknown-linux-gnu").build();
assert_eq!(config.target_cfg().rustc_abi, Some("x86-sse2".to_string()));
assert!(check_ignore(&config, "//@ ignore-rustc_abi-x86-sse2"));
assert!(!check_ignore(&config, "//@ only-rustc_abi-x86-sse2"));
let config = cfg().target("x86_64-unknown-linux-gnu").build();
assert_eq!(config.target_cfg().rustc_abi, None);
assert!(!check_ignore(&config, "//@ ignore-rustc_abi-x86-sse2"));
assert!(check_ignore(&config, "//@ only-rustc_abi-x86-sse2"));
}