Skip to content

Commit c9d097d

Browse files
authored
Merge pull request #4743 from rust-lang/rustup-2025-12-06
Automatic Rustup
2 parents 6cf7bd5 + 77825a2 commit c9d097d

File tree

105 files changed

+1892
-1073
lines changed

Some content is hidden

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

105 files changed

+1892
-1073
lines changed

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
9696
let generics = self.lower_delegation_generics(span);
9797
DelegationResults { body_id, sig, ident, generics }
9898
}
99-
Err(err) => self.generate_delegation_error(err, span),
99+
Err(err) => self.generate_delegation_error(err, span, delegation),
100100
}
101101
}
102102

@@ -404,6 +404,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
404404
&mut self,
405405
err: ErrorGuaranteed,
406406
span: Span,
407+
delegation: &Delegation,
407408
) -> DelegationResults<'hir> {
408409
let generics = self.lower_delegation_generics(span);
409410

@@ -418,8 +419,41 @@ impl<'hir> LoweringContext<'_, 'hir> {
418419
let header = self.generate_header_error();
419420
let sig = hir::FnSig { decl, header, span };
420421

421-
let ident = Ident::dummy();
422-
let body_id = self.lower_body(|this| (&[], this.mk_expr(hir::ExprKind::Err(err), span)));
422+
let ident = self.lower_ident(delegation.ident);
423+
424+
let body_id = self.lower_body(|this| {
425+
let body_expr = match delegation.body.as_ref() {
426+
Some(box block) => {
427+
// Generates a block when we failed to resolve delegation, where a target expression is its only statement,
428+
// thus there will be no ICEs on further stages of analysis (see #144594)
429+
430+
// As we generate a void function we want to convert target expression to statement to avoid additional
431+
// errors, such as mismatched return type
432+
let stmts = this.arena.alloc_from_iter([hir::Stmt {
433+
hir_id: this.next_id(),
434+
kind: rustc_hir::StmtKind::Semi(
435+
this.arena.alloc(this.lower_target_expr(block)),
436+
),
437+
span,
438+
}]);
439+
440+
let block = this.arena.alloc(hir::Block {
441+
stmts,
442+
expr: None,
443+
hir_id: this.next_id(),
444+
rules: hir::BlockCheckMode::DefaultBlock,
445+
span,
446+
targeted_by_break: false,
447+
});
448+
449+
hir::ExprKind::Block(block, None)
450+
}
451+
None => hir::ExprKind::Err(err),
452+
};
453+
454+
(&[], this.mk_expr(body_expr, span))
455+
});
456+
423457
DelegationResults { ident, generics, body_id, sig }
424458
}
425459

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3940,13 +3940,30 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
39403940
if let Some(decl) = local_decl
39413941
&& decl.can_be_made_mutable()
39423942
{
3943+
let is_for_loop = matches!(
3944+
decl.local_info(),
3945+
LocalInfo::User(BindingForm::Var(VarBindingForm {
3946+
opt_match_place: Some((_, match_span)),
3947+
..
3948+
})) if matches!(match_span.desugaring_kind(), Some(DesugaringKind::ForLoop))
3949+
);
3950+
let message = if is_for_loop
3951+
&& let Ok(binding_name) =
3952+
self.infcx.tcx.sess.source_map().span_to_snippet(decl.source_info.span)
3953+
{
3954+
format!("(mut {}) ", binding_name)
3955+
} else {
3956+
"mut ".to_string()
3957+
};
39433958
err.span_suggestion_verbose(
39443959
decl.source_info.span.shrink_to_lo(),
39453960
"consider making this binding mutable",
3946-
"mut ".to_string(),
3961+
message,
39473962
Applicability::MachineApplicable,
39483963
);
3964+
39493965
if !from_arg
3966+
&& !is_for_loop
39503967
&& matches!(
39513968
decl.local_info(),
39523969
LocalInfo::User(BindingForm::Var(VarBindingForm {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10611061

10621062
Rvalue::Cast(cast_kind, op, ty) => {
10631063
match *cast_kind {
1064-
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer, coercion_source) => {
1064+
CastKind::PointerCoercion(
1065+
PointerCoercion::ReifyFnPointer(target_safety),
1066+
coercion_source,
1067+
) => {
10651068
let is_implicit_coercion = coercion_source == CoercionSource::Implicit;
10661069
let src_ty = op.ty(self.body, tcx);
10671070
let mut src_sig = src_ty.fn_sig(tcx);
@@ -1078,6 +1081,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10781081
src_sig = safe_sig;
10791082
}
10801083

1084+
if src_sig.safety().is_safe() && target_safety.is_unsafe() {
1085+
src_sig = tcx.safe_to_unsafe_sig(src_sig);
1086+
}
1087+
10811088
// HACK: This shouldn't be necessary... We can remove this when we actually
10821089
// get binders with where clauses, then elaborate implied bounds into that
10831090
// binder, and implement a higher-ranked subtyping algorithm that actually

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
689689
lval.write_cvalue(fx, res);
690690
}
691691
Rvalue::Cast(
692-
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer, _),
692+
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer(_), _),
693693
ref operand,
694694
to_ty,
695695
) => {

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn write_output_file<'ll>(
7575
let result = unsafe {
7676
let pm = llvm::LLVMCreatePassManager();
7777
llvm::LLVMAddAnalysisPasses(target, pm);
78-
llvm::LLVMRustAddLibraryInfo(pm, m, no_builtins);
78+
llvm::LLVMRustAddLibraryInfo(target, pm, m, no_builtins);
7979
llvm::LLVMRustWriteOutputFile(
8080
target,
8181
pm,

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ impl CodegenBackend for LlvmCodegenBackend {
257257
}
258258
writeln!(out).unwrap();
259259
}
260+
PrintKind::BackendHasZstd => {
261+
let has_zstd = llvm::LLVMRustLLVMHasZstdCompression();
262+
writeln!(out, "{has_zstd}").unwrap();
263+
}
260264
PrintKind::CodeModels => {
261265
writeln!(out, "Available code models:").unwrap();
262266
for name in &["tiny", "small", "kernel", "medium", "large"] {

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,7 @@ unsafe extern "C" {
23792379
) -> *mut TargetMachine;
23802380

23812381
pub(crate) fn LLVMRustAddLibraryInfo<'a>(
2382+
T: &TargetMachine,
23822383
PM: &PassManager<'a>,
23832384
M: &'a Module,
23842385
DisableSimplifyLibCalls: bool,

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
405405
let lladdr = bx.ptrtoint(llptr, llcast_ty);
406406
OperandValue::Immediate(lladdr)
407407
}
408-
mir::CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer, _) => {
408+
mir::CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer(_), _) => {
409409
match *operand.layout.ty.kind() {
410410
ty::FnDef(def_id, args) => {
411411
let instance = ty::Instance::resolve_for_fn_ptr(

compiler/rustc_codegen_ssa/src/traits/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes {
3636
vtable_byte_offset: u64,
3737
typeid: Self::Metadata,
3838
) -> Self::Value;
39-
/// Trait method used to inject `va_start` on the "spoofed" `VaListImpl` in
39+
/// Trait method used to inject `va_start` on the "spoofed" `VaList` in
4040
/// Rust defined C-variadic functions.
4141
fn va_start(&mut self, val: Self::Value) -> Self::Value;
42-
/// Trait method used to inject `va_end` on the "spoofed" `VaListImpl` before
42+
/// Trait method used to inject `va_end` on the "spoofed" `VaList` before
4343
/// Rust defined C-variadic functions return.
4444
fn va_end(&mut self, val: Self::Value) -> Self::Value;
4545
}

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
627627
| PointerCoercion::ArrayToPointer
628628
| PointerCoercion::UnsafeFnPointer
629629
| PointerCoercion::ClosureFnPointer(_)
630-
| PointerCoercion::ReifyFnPointer,
630+
| PointerCoercion::ReifyFnPointer(_),
631631
_,
632632
),
633633
_,

0 commit comments

Comments
 (0)