Skip to content

Commit 941a971

Browse files
authored
Merge pull request #4385 from rust-lang/rustup-2025-06-08
Automatic Rustup
2 parents 31e9806 + 1894b49 commit 941a971

File tree

108 files changed

+1335
-623
lines changed

Some content is hidden

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

108 files changed

+1335
-623
lines changed

compiler/rustc_abi/src/extern_abi.rs

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,93 @@ use crate::AbiFromStrErr;
1212
#[cfg(test)]
1313
mod tests;
1414

15-
use ExternAbi as Abi;
16-
15+
/// ABI we expect to see within `extern "{abi}"`
1716
#[derive(Clone, Copy, Debug)]
1817
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable))]
1918
pub enum ExternAbi {
20-
// Some of the ABIs come first because every time we add a new ABI, we have to re-bless all the
21-
// hashing tests. These are used in many places, so giving them stable values reduces test
22-
// churn. The specific values are meaningless.
23-
Rust,
19+
/* universal */
20+
/// presumed C ABI for the platform
2421
C {
2522
unwind: bool,
2623
},
27-
Cdecl {
24+
/// ABI of the "system" interface, e.g. the Win32 API, always "aliasing"
25+
System {
2826
unwind: bool,
2927
},
30-
Stdcall {
28+
29+
/// that's us!
30+
Rust,
31+
/// the mostly-unused `unboxed_closures` ABI, effectively now an impl detail unless someone
32+
/// puts in the work to make it viable again... but would we need a special ABI?
33+
RustCall,
34+
/// For things unlikely to be called, where reducing register pressure in
35+
/// `extern "Rust"` callers is worth paying extra cost in the callee.
36+
/// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
37+
RustCold,
38+
39+
/// Unstable impl detail that directly uses Rust types to describe the ABI to LLVM.
40+
/// Even normally-compatible Rust types can become ABI-incompatible with this ABI!
41+
Unadjusted,
42+
43+
/// UEFI ABI, usually an alias of C, but sometimes an arch-specific alias
44+
/// and only valid on platforms that have a UEFI standard
45+
EfiApi,
46+
47+
/* arm */
48+
/// Arm Architecture Procedure Call Standard, sometimes `ExternAbi::C` is an alias for this
49+
Aapcs {
3150
unwind: bool,
3251
},
33-
Fastcall {
52+
/// extremely constrained barely-C ABI for TrustZone
53+
CCmseNonSecureCall,
54+
/// extremely constrained barely-C ABI for TrustZone
55+
CCmseNonSecureEntry,
56+
57+
/* gpu */
58+
/// An entry-point function called by the GPU's host
59+
// FIXME: should not be callable from Rust on GPU targets, is for host's use only
60+
GpuKernel,
61+
/// An entry-point function called by the GPU's host
62+
// FIXME: why do we have two of these?
63+
PtxKernel,
64+
65+
/* interrupt */
66+
AvrInterrupt,
67+
AvrNonBlockingInterrupt,
68+
Msp430Interrupt,
69+
RiscvInterruptM,
70+
RiscvInterruptS,
71+
X86Interrupt,
72+
73+
/* x86 */
74+
/// `ExternAbi::C` but spelled funny because x86
75+
Cdecl {
3476
unwind: bool,
3577
},
36-
Vectorcall {
78+
/// gnu-stdcall on "unix" and win-stdcall on "windows"
79+
Stdcall {
3780
unwind: bool,
3881
},
39-
Thiscall {
82+
/// gnu-fastcall on "unix" and win-fastcall on "windows"
83+
Fastcall {
4084
unwind: bool,
4185
},
42-
Aapcs {
86+
/// windows C++ ABI
87+
Thiscall {
4388
unwind: bool,
4489
},
45-
Win64 {
90+
/// uses AVX and stuff
91+
Vectorcall {
4692
unwind: bool,
4793
},
94+
95+
/* x86_64 */
4896
SysV64 {
4997
unwind: bool,
5098
},
51-
PtxKernel,
52-
Msp430Interrupt,
53-
X86Interrupt,
54-
/// An entry-point function called by the GPU's host
55-
// FIXME: should not be callable from Rust on GPU targets, is for host's use only
56-
GpuKernel,
57-
EfiApi,
58-
AvrInterrupt,
59-
AvrNonBlockingInterrupt,
60-
CCmseNonSecureCall,
61-
CCmseNonSecureEntry,
62-
System {
99+
Win64 {
63100
unwind: bool,
64101
},
65-
RustCall,
66-
/// *Not* a stable ABI, just directly use the Rust types to describe the ABI for LLVM. Even
67-
/// normally ABI-compatible Rust types can become ABI-incompatible with this ABI!
68-
Unadjusted,
69-
/// For things unlikely to be called, where reducing register pressure in
70-
/// `extern "Rust"` callers is worth paying extra cost in the callee.
71-
/// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
72-
RustCold,
73-
RiscvInterruptM,
74-
RiscvInterruptS,
75102
}
76103

77104
macro_rules! abi_impls {
@@ -224,7 +251,7 @@ pub fn all_names() -> Vec<&'static str> {
224251

225252
impl ExternAbi {
226253
/// Default ABI chosen for `extern fn` declarations without an explicit ABI.
227-
pub const FALLBACK: Abi = Abi::C { unwind: false };
254+
pub const FALLBACK: ExternAbi = ExternAbi::C { unwind: false };
228255

229256
pub fn name(self) -> &'static str {
230257
self.as_str()

compiler/rustc_codegen_cranelift/example/neon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ unsafe fn test_vaddvq_f32() {
233233

234234
#[cfg(target_arch = "aarch64")]
235235
unsafe fn test_vrndnq_f32() {
236-
// AArch64 llvm intrinsic: llvm.aarch64.neon.frintn.v4f32
236+
// llvm intrinsic: llvm.roundeven.v4f32
237237
let a = f32x4::from([0.1, -1.9, 4.5, 5.5]);
238238
let e = f32x4::from([0., -2., 4., 6.]);
239239
let r: f32x4 = transmute(vrndnq_f32(transmute(a)));

compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
6262
});
6363
}
6464

65+
_ if intrinsic.starts_with("llvm.roundeven.v") => {
66+
intrinsic_args!(fx, args => (v); intrinsic);
67+
68+
simd_for_each_lane(fx, v, ret, &|fx, _lane_ty, _res_lane_ty, lane| {
69+
fx.bcx.ins().nearest(lane)
70+
});
71+
}
72+
6573
_ => {
6674
fx.tcx
6775
.dcx()

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_aarch64.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,6 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
264264
simd_reduce(fx, v, None, ret, &|fx, _ty, a, b| fx.bcx.ins().fadd(a, b));
265265
}
266266

267-
_ if intrinsic.starts_with("llvm.aarch64.neon.frintn.v") => {
268-
intrinsic_args!(fx, args => (v); intrinsic);
269-
270-
simd_for_each_lane(fx, v, ret, &|fx, _lane_ty, _res_lane_ty, lane| {
271-
fx.bcx.ins().nearest(lane)
272-
});
273-
}
274-
275267
_ if intrinsic.starts_with("llvm.aarch64.neon.smaxv.i") => {
276268
intrinsic_args!(fx, args => (v); intrinsic);
277269

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ impl DiagCtxtInner {
15291529
// Future breakages aren't emitted if they're `Level::Allow` or
15301530
// `Level::Expect`, but they still need to be constructed and
15311531
// stashed below, so they'll trigger the must_produce_diag check.
1532-
assert_matches!(diagnostic.level, Error | Warning | Allow | Expect);
1532+
assert_matches!(diagnostic.level, Error | ForceWarning | Warning | Allow | Expect);
15331533
self.future_breakage_diagnostics.push(diagnostic.clone());
15341534
}
15351535

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
192192
let _: R = tcx.ensure_ok().crate_inherent_impls_overlap_check(());
193193
});
194194

195-
// Make sure we evaluate all static and (non-associated) const items, even if unused.
196-
// If any of these fail to evaluate, we do not want this crate to pass compilation.
197195
tcx.par_hir_body_owners(|item_def_id| {
198196
let def_kind = tcx.def_kind(item_def_id);
197+
// Make sure we evaluate all static and (non-associated) const items, even if unused.
198+
// If any of these fail to evaluate, we do not want this crate to pass compilation.
199199
match def_kind {
200200
DefKind::Static { .. } => {
201201
tcx.ensure_ok().eval_static_initializer(item_def_id);
@@ -215,6 +215,11 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
215215
if !matches!(def_kind, DefKind::AnonConst) {
216216
tcx.ensure_ok().typeck(item_def_id);
217217
}
218+
// Ensure we generate the new `DefId` before finishing `check_crate`.
219+
// Afterwards we freeze the list of `DefId`s.
220+
if tcx.needs_coroutine_by_move_body_def_id(item_def_id.to_def_id()) {
221+
tcx.ensure_done().coroutine_by_move_body_def_id(item_def_id);
222+
}
218223
});
219224

220225
if tcx.features().rustc_attrs() {

compiler/rustc_hir_typeck/src/cast.rs

Lines changed: 43 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,21 @@ impl<'a, 'tcx> CastCheck<'tcx> {
380380
err.span_label(self.span, "invalid cast");
381381
if self.expr_ty.is_numeric() {
382382
if self.expr_ty == fcx.tcx.types.u32 {
383-
match fcx.tcx.sess.source_map().span_to_snippet(self.expr.span) {
384-
Ok(snippet) => err.span_suggestion(
385-
self.span,
386-
"try `char::from_u32` instead",
387-
format!("char::from_u32({snippet})"),
388-
Applicability::MachineApplicable,
389-
),
390-
391-
Err(_) => err.span_help(self.span, "try `char::from_u32` instead"),
392-
};
383+
err.multipart_suggestion(
384+
"consider using `char::from_u32` instead",
385+
vec![
386+
(self.expr_span.shrink_to_lo(), "char::from_u32(".to_string()),
387+
(self.expr_span.shrink_to_hi().to(self.cast_span), ")".to_string()),
388+
],
389+
Applicability::MachineApplicable,
390+
);
393391
} else if self.expr_ty == fcx.tcx.types.i8 {
394-
err.span_help(self.span, "try casting from `u8` instead");
392+
err.span_help(self.span, "consider casting from `u8` instead");
395393
} else {
396-
err.span_help(self.span, "try `char::from_u32` instead (via a `u32`)");
394+
err.span_help(
395+
self.span,
396+
"consider using `char::from_u32` instead (via a `u32`)",
397+
);
397398
};
398399
}
399400
err.emit();
@@ -494,38 +495,31 @@ impl<'a, 'tcx> CastCheck<'tcx> {
494495
self.cast_ty.kind(),
495496
ty::FnDef(..) | ty::FnPtr(..) | ty::Closure(..)
496497
) {
497-
let mut label = true;
498498
// Check `impl From<self.expr_ty> for self.cast_ty {}` for accurate suggestion:
499-
if let Ok(snippet) = fcx.tcx.sess.source_map().span_to_snippet(self.expr_span)
500-
&& let Some(from_trait) = fcx.tcx.get_diagnostic_item(sym::From)
501-
{
499+
if let Some(from_trait) = fcx.tcx.get_diagnostic_item(sym::From) {
502500
let ty = fcx.resolve_vars_if_possible(self.cast_ty);
503501
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
504502
if fcx
505503
.infcx
506504
.type_implements_trait(from_trait, [ty, expr_ty], fcx.param_env)
507505
.must_apply_modulo_regions()
508506
{
509-
label = false;
510-
if let ty::Adt(def, args) = self.cast_ty.kind() {
511-
err.span_suggestion_verbose(
512-
self.span,
513-
"consider using the `From` trait instead",
514-
format!(
515-
"{}::from({})",
516-
fcx.tcx.value_path_str_with_args(def.did(), args),
517-
snippet
518-
),
519-
Applicability::MaybeIncorrect,
520-
);
507+
let to_ty = if let ty::Adt(def, args) = self.cast_ty.kind() {
508+
fcx.tcx.value_path_str_with_args(def.did(), args)
521509
} else {
522-
err.span_suggestion(
523-
self.span,
524-
"consider using the `From` trait instead",
525-
format!("{}::from({})", self.cast_ty, snippet),
526-
Applicability::MaybeIncorrect,
527-
);
510+
self.cast_ty.to_string()
528511
};
512+
err.multipart_suggestion(
513+
"consider using the `From` trait instead",
514+
vec![
515+
(self.expr_span.shrink_to_lo(), format!("{to_ty}::from(")),
516+
(
517+
self.expr_span.shrink_to_hi().to(self.cast_span),
518+
")".to_string(),
519+
),
520+
],
521+
Applicability::MaybeIncorrect,
522+
);
529523
}
530524
}
531525

@@ -548,11 +542,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
548542
)
549543
};
550544

551-
if label {
552-
err.span_label(self.span, msg);
553-
} else {
554-
err.note(msg);
555-
}
545+
err.span_label(self.span, msg);
556546

557547
if let Some(note) = note {
558548
err.note(note);
@@ -654,38 +644,22 @@ impl<'a, 'tcx> CastCheck<'tcx> {
654644
match self.expr_ty.kind() {
655645
ty::Ref(_, _, mt) => {
656646
let mtstr = mt.prefix_str();
657-
match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) {
658-
Ok(s) => {
659-
err.span_suggestion(
660-
self.cast_span,
661-
"try casting to a reference instead",
662-
format!("&{mtstr}{s}"),
663-
Applicability::MachineApplicable,
664-
);
665-
}
666-
Err(_) => {
667-
let msg = format!("did you mean `&{mtstr}{tstr}`?");
668-
err.span_help(self.cast_span, msg);
669-
}
670-
}
647+
err.span_suggestion_verbose(
648+
self.cast_span.shrink_to_lo(),
649+
"consider casting to a reference instead",
650+
format!("&{mtstr}"),
651+
Applicability::MachineApplicable,
652+
);
671653
}
672654
ty::Adt(def, ..) if def.is_box() => {
673-
match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) {
674-
Ok(s) => {
675-
err.span_suggestion(
676-
self.cast_span,
677-
"you can cast to a `Box` instead",
678-
format!("Box<{s}>"),
679-
Applicability::MachineApplicable,
680-
);
681-
}
682-
Err(_) => {
683-
err.span_help(
684-
self.cast_span,
685-
format!("you might have meant `Box<{tstr}>`"),
686-
);
687-
}
688-
}
655+
err.multipart_suggestion(
656+
"you can cast to a `Box` instead",
657+
vec![
658+
(self.cast_span.shrink_to_lo(), "Box<".to_string()),
659+
(self.cast_span.shrink_to_hi(), ">".to_string()),
660+
],
661+
Applicability::MachineApplicable,
662+
);
689663
}
690664
_ => {
691665
err.span_help(self.expr_span, "consider using a box or reference as appropriate");

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,13 @@ impl<'tcx> InferCtxt<'tcx> {
823823
ty::Region::new_var(self.tcx, region_var)
824824
}
825825

826+
pub fn next_term_var_of_kind(&self, term: ty::Term<'tcx>, span: Span) -> ty::Term<'tcx> {
827+
match term.kind() {
828+
ty::TermKind::Ty(_) => self.next_ty_var(span).into(),
829+
ty::TermKind::Const(_) => self.next_const_var(span).into(),
830+
}
831+
}
832+
826833
/// Return the universe that the region `r` was created in. For
827834
/// most regions (e.g., `'static`, named regions from the user,
828835
/// etc) this is the root universe U0. For inference variables or

compiler/rustc_interface/src/passes.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -976,13 +976,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
976976
});
977977

978978
rustc_hir_analysis::check_crate(tcx);
979-
sess.time("MIR_coroutine_by_move_body", || {
980-
tcx.par_hir_body_owners(|def_id| {
981-
if tcx.needs_coroutine_by_move_body_def_id(def_id.to_def_id()) {
982-
tcx.ensure_done().coroutine_by_move_body_def_id(def_id);
983-
}
984-
});
985-
});
986979
// Freeze definitions as we don't add new ones at this point.
987980
// We need to wait until now since we synthesize a by-move body
988981
// for all coroutine-closures.

0 commit comments

Comments
 (0)