Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 9b4d7c6

Browse files
committed
Auto merge of rust-lang#133568 - GuillaumeGomez:rollup-js22ovb, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#133358 (Don't type error if we fail to coerce `Pin<T>` because it doesnt contain a ref) - rust-lang#133422 (Fix clobber_abi in RV32E and RV64E inline assembly) - rust-lang#133452 (Support predicate registers (clobber-only) in Hexagon inline assembly) - rust-lang#133463 (Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with -Zfixed-x18) - rust-lang#133487 (fix confusing diagnostic for reserved `##`) - rust-lang#133557 (Small doc fixes in `rustc_codegen_ssa`) - rust-lang#133560 (Trim extra space in 'repeated `mut`' diagnostic) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c1cfab2 + 22c5bb0 commit 9b4d7c6

Some content is hidden

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

50 files changed

+438
-186
lines changed

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
8282
let mut clobber_abis = FxIndexMap::default();
8383
if let Some(asm_arch) = asm_arch {
8484
for (abi_name, abi_span) in &asm.clobber_abis {
85-
match asm::InlineAsmClobberAbi::parse(asm_arch, &self.tcx.sess.target, *abi_name) {
85+
match asm::InlineAsmClobberAbi::parse(
86+
asm_arch,
87+
&self.tcx.sess.target,
88+
&self.tcx.sess.unstable_target_features,
89+
*abi_name,
90+
) {
8691
Ok(abi) => {
8792
// If the abi was already in the list, emit an error
8893
match clobber_abis.get(&abi) {

compiler/rustc_codegen_cranelift/src/inline_asm.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,14 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
476476
let mut new_slot = |x| new_slot_fn(&mut slot_size, x);
477477

478478
// Allocate stack slots for saving clobbered registers
479-
let abi_clobber = InlineAsmClobberAbi::parse(self.arch, &self.tcx.sess.target, sym::C)
480-
.unwrap()
481-
.clobbered_regs();
479+
let abi_clobber = InlineAsmClobberAbi::parse(
480+
self.arch,
481+
&self.tcx.sess.target,
482+
&self.tcx.sess.unstable_target_features,
483+
sym::C,
484+
)
485+
.unwrap()
486+
.clobbered_regs();
482487
for (i, reg) in self.registers.iter().enumerate().filter_map(|(i, r)| r.map(|r| (i, r))) {
483488
let mut need_save = true;
484489
// If the register overlaps with a register clobbered by function call, then

compiler/rustc_codegen_gcc/src/asm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
634634
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r",
635635
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => "w",
636636
InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::reg) => "r",
637+
InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::preg) => {
638+
unreachable!("clobber-only")
639+
}
637640
InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::reg) => "r",
638641
InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::freg) => "f",
639642
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => "r",
@@ -720,6 +723,9 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
720723
cx.type_vector(cx.type_i64(), 2)
721724
}
722725
InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::reg) => cx.type_i32(),
726+
InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::preg) => {
727+
unreachable!("clobber-only")
728+
}
723729
InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::reg) => cx.type_i32(),
724730
InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::freg) => cx.type_f32(),
725731
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => cx.type_i32(),

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
645645
| Arm(ArmInlineAsmRegClass::qreg_low4) => "x",
646646
Arm(ArmInlineAsmRegClass::dreg) | Arm(ArmInlineAsmRegClass::qreg) => "w",
647647
Hexagon(HexagonInlineAsmRegClass::reg) => "r",
648+
Hexagon(HexagonInlineAsmRegClass::preg) => unreachable!("clobber-only"),
648649
LoongArch(LoongArchInlineAsmRegClass::reg) => "r",
649650
LoongArch(LoongArchInlineAsmRegClass::freg) => "f",
650651
Mips(MipsInlineAsmRegClass::reg) => "r",
@@ -813,6 +814,7 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
813814
| Arm(ArmInlineAsmRegClass::qreg_low8)
814815
| Arm(ArmInlineAsmRegClass::qreg_low4) => cx.type_vector(cx.type_i64(), 2),
815816
Hexagon(HexagonInlineAsmRegClass::reg) => cx.type_i32(),
817+
Hexagon(HexagonInlineAsmRegClass::preg) => unreachable!("clobber-only"),
816818
LoongArch(LoongArchInlineAsmRegClass::reg) => cx.type_i32(),
817819
LoongArch(LoongArchInlineAsmRegClass::freg) => cx.type_f32(),
818820
Mips(MipsInlineAsmRegClass::reg) => cx.type_i32(),

compiler/rustc_codegen_ssa/src/traits/backend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ pub trait CodegenBackend {
7171
need_metadata_module: bool,
7272
) -> Box<dyn Any>;
7373

74-
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`
74+
/// This is called on the returned `Box<dyn Any>` from [`codegen_crate`](Self::codegen_crate)
7575
///
7676
/// # Panics
7777
///
78-
/// Panics when the passed `Box<dyn Any>` was not returned by `codegen_backend`.
78+
/// Panics when the passed `Box<dyn Any>` was not returned by [`codegen_crate`](Self::codegen_crate).
7979
fn join_codegen(
8080
&self,
8181
ongoing_codegen: Box<dyn Any>,
8282
sess: &Session,
8383
outputs: &OutputFilenames,
8484
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>);
8585

86-
/// This is called on the returned `CodegenResults` from `join_codegen`
86+
/// This is called on the returned [`CodegenResults`] from [`join_codegen`](Self::join_codegen).
8787
fn link(
8888
&self,
8989
sess: &Session,

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
215215
}
216216
}
217217

218-
// Examine the supertype and consider auto-borrowing.
218+
// Examine the supertype and consider type-specific coercions, such
219+
// as auto-borrowing, coercing pointer mutability, a `dyn*` coercion,
220+
// or pin-ergonomics.
219221
match *b.kind() {
220222
ty::RawPtr(_, b_mutbl) => {
221223
return self.coerce_unsafe_ptr(a, b, b_mutbl);
@@ -230,7 +232,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
230232
if self.tcx.features().pin_ergonomics()
231233
&& self.tcx.is_lang_item(pin.did(), hir::LangItem::Pin) =>
232234
{
233-
return self.coerce_pin(a, b);
235+
let pin_coerce = self.commit_if_ok(|_| self.coerce_pin_ref(a, b));
236+
if pin_coerce.is_ok() {
237+
return pin_coerce;
238+
}
234239
}
235240
_ => {}
236241
}
@@ -797,7 +802,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
797802
/// - `Pin<Box<T>>` as `Pin<&T>`
798803
/// - `Pin<Box<T>>` as `Pin<&mut T>`
799804
#[instrument(skip(self), level = "trace")]
800-
fn coerce_pin(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'tcx> {
805+
fn coerce_pin_ref(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'tcx> {
801806
// We need to make sure the two types are compatible for coercion.
802807
// Then we will build a ReborrowPin adjustment and return that as an InferOk.
803808

compiler/rustc_lint/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ lint_renamed_lint = lint `{$name}` has been renamed to `{$replace}`
733733
734734
lint_requested_level = requested on the command line with `{$level} {$lint_name}`
735735
736+
lint_reserved_multihash = reserved token in Rust 2024
737+
.suggestion = insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024
738+
736739
lint_reserved_prefix = prefix `{$prefix}` is unknown
737740
.label = unknown prefix
738741
.suggestion = insert whitespace here to avoid this being parsed as a prefix in Rust 2021

compiler/rustc_lint/src/context/diagnostics.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,12 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &
176176
lints::RawPrefix { label: label_span, suggestion: label_span.shrink_to_hi() }
177177
.decorate_lint(diag);
178178
}
179-
BuiltinLintDiag::ReservedString(suggestion) => {
180-
lints::ReservedString { suggestion }.decorate_lint(diag);
179+
BuiltinLintDiag::ReservedString { is_string, suggestion } => {
180+
if is_string {
181+
lints::ReservedString { suggestion }.decorate_lint(diag);
182+
} else {
183+
lints::ReservedMultihash { suggestion }.decorate_lint(diag);
184+
}
181185
}
182186
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
183187
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name }.decorate_lint(diag);

compiler/rustc_lint/src/lints.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,3 +3059,10 @@ pub(crate) struct ReservedString {
30593059
#[suggestion(code = " ", applicability = "machine-applicable")]
30603060
pub suggestion: Span,
30613061
}
3062+
3063+
#[derive(LintDiagnostic)]
3064+
#[diag(lint_reserved_multihash)]
3065+
pub(crate) struct ReservedMultihash {
3066+
#[suggestion(code = " ", applicability = "machine-applicable")]
3067+
pub suggestion: Span,
3068+
}

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,11 @@ pub enum BuiltinLintDiag {
663663
ReservedPrefix(Span, String),
664664
/// `'r#` in edition < 2021.
665665
RawPrefix(Span),
666-
/// `##` or `#"` is edition < 2024.
667-
ReservedString(Span),
666+
/// `##` or `#"` in edition < 2024.
667+
ReservedString {
668+
is_string: bool,
669+
suggestion: Span,
670+
},
668671
TrailingMacro(bool, Ident),
669672
BreakWithLabelAndLoop(Span),
670673
UnicodeTextFlow(Span, String),

0 commit comments

Comments
 (0)