Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6d9f6ae

Browse files
committedDec 16, 2024
Auto merge of rust-lang#134395 - matthiaskrgr:rollup-4j2gx1x, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#134124 (CI: use free runners for x86_64-gnu-llvm jobs) - rust-lang#134197 (rustc_mir_build: Clarify that 'mirrored' does not mean 'flipped' or 'reversed') - rust-lang#134260 (Correctly handle comments in attributes in doctests source code) - rust-lang#134277 (rustdoc-search: handle `impl Into<X>` better) - rust-lang#134284 (Keep track of patterns that could have introduced a binding, but didn't) - rust-lang#134337 (reject unsound toggling of RISCV target features) - rust-lang#134371 (Check for array lengths that aren't actually `usize`) - rust-lang#134385 (tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro features by using minicore) - rust-lang#134386 (Some trait method vs impl method signature difference diagnostic cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 83ab648 + 9a0dab2 commit 6d9f6ae

File tree

81 files changed

+1223
-760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1223
-760
lines changed
 

‎compiler/rustc_target/src/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,7 @@ impl Target {
31663166
// Note that the `lp64e` is still unstable as it's not (yet) part of the ELF psABI.
31673167
check_matches!(
31683168
&*self.llvm_abiname,
3169-
"lp64" | "lp64f" | "lp64d" | "lp64q" | "lp64e",
3169+
"lp64" | "lp64f" | "lp64d" | "lp64e",
31703170
"invalid RISC-V ABI name"
31713171
);
31723172
}

‎compiler/rustc_target/src/target_features.rs

+71-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum Stability<Toggleability> {
3939
allow_toggle: Toggleability,
4040
},
4141
/// This feature can not be set via `-Ctarget-feature` or `#[target_feature]`, it can only be
42-
/// set in the basic target definition. It is never set in `cfg(target_feature)`. Used in
42+
/// set in the target spec. It is never set in `cfg(target_feature)`. Used in
4343
/// particular for features that change the floating-point ABI.
4444
Forbidden { reason: &'static str },
4545
}
@@ -590,9 +590,76 @@ const RISCV_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
590590
// tidy-alphabetical-start
591591
("a", STABLE, &["zaamo", "zalrsc"]),
592592
("c", STABLE, &[]),
593-
("d", unstable(sym::riscv_target_feature), &["f"]),
594-
("e", unstable(sym::riscv_target_feature), &[]),
595-
("f", unstable(sym::riscv_target_feature), &[]),
593+
(
594+
"d",
595+
Stability::Unstable {
596+
nightly_feature: sym::riscv_target_feature,
597+
allow_toggle: |target, enable| match &*target.llvm_abiname {
598+
"ilp32d" | "lp64d" if !enable => {
599+
// The ABI requires the `d` feature, so it cannot be disabled.
600+
Err("feature is required by ABI")
601+
}
602+
"ilp32e" if enable => {
603+
// ilp32e is incompatible with features that need aligned load/stores > 32 bits,
604+
// like `d`.
605+
Err("feature is incompatible with ABI")
606+
}
607+
_ => Ok(()),
608+
},
609+
},
610+
&["f"],
611+
),
612+
(
613+
"e",
614+
Stability::Unstable {
615+
// Given that this is a negative feature, consider this before stabilizing:
616+
// does it really make sense to enable this feature in an individual
617+
// function with `#[target_feature]`?
618+
nightly_feature: sym::riscv_target_feature,
619+
allow_toggle: |target, enable| {
620+
match &*target.llvm_abiname {
621+
_ if !enable => {
622+
// Disabling this feature means we can use more registers (x16-x31).
623+
// The "e" ABIs treat them as caller-save, so it is safe to use them only
624+
// in some parts of a program while the rest doesn't know they even exist.
625+
// On other ABIs, the feature is already disabled anyway.
626+
Ok(())
627+
}
628+
"ilp32e" | "lp64e" => {
629+
// Embedded ABIs should already have the feature anyway, it's fine to enable
630+
// it again from an ABI perspective.
631+
Ok(())
632+
}
633+
_ => {
634+
// *Not* an embedded ABI. Enabling `e` is invalid.
635+
Err("feature is incompatible with ABI")
636+
}
637+
}
638+
},
639+
},
640+
&[],
641+
),
642+
(
643+
"f",
644+
Stability::Unstable {
645+
nightly_feature: sym::riscv_target_feature,
646+
allow_toggle: |target, enable| {
647+
match &*target.llvm_abiname {
648+
"ilp32f" | "ilp32d" | "lp64f" | "lp64d" if !enable => {
649+
// The ABI requires the `f` feature, so it cannot be disabled.
650+
Err("feature is required by ABI")
651+
}
652+
_ => Ok(()),
653+
}
654+
},
655+
},
656+
&[],
657+
),
658+
(
659+
"forced-atomics",
660+
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
661+
&[],
662+
),
596663
("m", STABLE, &[]),
597664
("relax", unstable(sym::riscv_target_feature), &[]),
598665
("unaligned-scalar-mem", unstable(sym::riscv_target_feature), &[]),
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.