Skip to content

Commit 4ccb54e

Browse files
committed
Auto merge of #158581 - JonathanBrouwer:rollup-96RiQZV, r=<try>
Rollup of 14 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-2
2 parents 7dc2c16 + 0f18792 commit 4ccb54e

151 files changed

Lines changed: 3270 additions & 512 deletions

File tree

Some content is hidden

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

bootstrap.example.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,13 @@
697697
# FIXME(#61117): Some tests fail when this option is enabled.
698698
#rust.debuginfo-level-tests = 0
699699

700+
# Compress debuginfo of Rust and C/C++ code.
701+
# Valid options:
702+
# - "off" or false: disable compression
703+
# - true: compress debuginfo with the default compression method (currently zlib)
704+
# - "zlib": compress debuginfo with zlib
705+
#rust.compress-debuginfo = "off"
706+
700707
# Should rustc and the standard library be built with split debuginfo? Default
701708
# is platform dependent.
702709
#
@@ -1019,6 +1026,13 @@
10191026
# and enabling it causes issues.
10201027
#split-debuginfo = if linux || windows-gnu { off } else if windows-msvc { packed } else if apple { unpacked }
10211028

1029+
# Compress debuginfo for Rust and C/C++ code of this target.
1030+
# Valid options:
1031+
# - "off" or false: disable compression
1032+
# - true: compress debuginfo with the default compression method (currently zlib)
1033+
# - "zlib": compress debuginfo with zlib
1034+
#compress-debuginfo = "off"
1035+
10221036
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
10231037
# against. Note that if this is specified we don't compile LLVM at all for this
10241038
# target.

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ use rustc_span::def_id::{DefId, LocalDefId};
5555
use rustc_span::symbol::kw;
5656
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
5757

58-
use crate::delegation::generics::{GenericsGenerationResult, GenericsGenerationResults};
58+
use crate::delegation::generics::{
59+
GenericsGenerationResult, GenericsGenerationResults, GenericsPosition,
60+
};
5961
use crate::diagnostics::{
6062
CycleInDelegationSignatureResolution, DelegationAttemptedBlockWithDefsDeletion,
6163
DelegationBlockSpecifiedWhenNoParams, UnresolvedDelegationCallee,
@@ -505,6 +507,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
505507
res: Res::Local(param_id),
506508
args: None,
507509
infer_args: false,
510+
delegation_child_segment: false,
508511
}));
509512

510513
let path = self.arena.alloc(hir::Path { span, res: Res::Local(param_id), segments });
@@ -714,6 +717,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
714717
result.args_segment_id = segment.hir_id;
715718
result.use_for_sig_inheritance = !result.generics.is_trait_impl();
716719

720+
segment.delegation_child_segment = result.generics.pos() == GenericsPosition::Child;
721+
717722
segment
718723
}
719724

compiler/rustc_ast_lowering/src/delegation/generics.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_span::{Ident, Span, sym};
1212
use crate::LoweringContext;
1313
use crate::diagnostics::DelegationInfersMismatch;
1414

15-
#[derive(Debug, Clone, Copy)]
15+
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
1616
pub(super) enum GenericsPosition {
1717
Parent,
1818
Child,
@@ -155,7 +155,7 @@ impl<'hir> DelegationGenericArgsIterator<'hir> {
155155
impl<'hir> HirOrTyGenerics<'hir> {
156156
pub(super) fn into_hir_generics(&mut self, ctx: &mut LoweringContext<'_, 'hir>, span: Span) {
157157
if let HirOrTyGenerics::Ty(ty) = self {
158-
let rename_self = matches!(ty.pos, GenericsPosition::Child);
158+
let rename_self = ty.pos == GenericsPosition::Child;
159159
let params = ctx.uplift_delegation_generic_params(span, &ty.data, rename_self);
160160

161161
*self = HirOrTyGenerics::Hir(DelegationGenerics {
@@ -218,6 +218,13 @@ impl<'hir> HirOrTyGenerics<'hir> {
218218
.expect("`Self` generic param is not found while expected"),
219219
}
220220
}
221+
222+
pub(crate) fn pos(&self) -> GenericsPosition {
223+
match self {
224+
HirOrTyGenerics::Ty(ty) => ty.pos,
225+
HirOrTyGenerics::Hir(hir) => hir.pos,
226+
}
227+
}
221228
}
222229

223230
impl<'hir> GenericsGenerationResult<'hir> {
@@ -590,6 +597,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
590597
ident: p.name.ident(),
591598
infer_args: false,
592599
res,
600+
delegation_child_segment: false,
593601
}]),
594602
res,
595603
span: p.span,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10141014
res,
10151015
args,
10161016
infer_args: args.is_none(),
1017+
delegation_child_segment: false,
10171018
}]),
10181019
})
10191020
}
@@ -2791,7 +2792,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
27912792
}
27922793
ExprKind::ConstBlock(anon_const) => {
27932794
let def_id = self.local_def_id(anon_const.id);
2794-
assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
2795+
assert_eq!(DefKind::InlineConst, self.tcx.def_kind(def_id));
27952796
self.lower_anon_const_to_const_arg(anon_const, span)
27962797
}
27972798
_ => overly_complex_const(self),

compiler/rustc_ast_lowering/src/path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
412412
} else {
413413
Some(generic_args.into_generic_args(self))
414414
},
415+
delegation_child_segment: false,
415416
}
416417
}
417418

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use rustc_span::edition::Edition::Edition2024;
88
use super::prelude::*;
99
use crate::attributes::AttributeSafety;
1010
use crate::session_diagnostics::{
11-
EmptyExportName, NakedFunctionIncompatibleAttribute, NullOnExport, NullOnObjcClass,
12-
NullOnObjcSelector, ObjcClassExpectedStringLiteral, ObjcSelectorExpectedStringLiteral,
13-
SanitizeInvalidStatic, TargetFeatureOnLangItem,
11+
EmptyExportName, EmptySection, NakedFunctionIncompatibleAttribute, NullOnExport,
12+
NullOnObjcClass, NullOnObjcSelector, NullOnSection, ObjcClassExpectedStringLiteral,
13+
ObjcSelectorExpectedStringLiteral, SanitizeInvalidStatic, TargetFeatureOnLangItem,
1414
};
1515
use crate::target_checking::Policy::AllowSilent;
1616

@@ -795,82 +795,94 @@ pub(crate) struct PatchableFunctionEntryParser;
795795
impl SingleAttributeParser for PatchableFunctionEntryParser {
796796
const PATH: &[Symbol] = &[sym::patchable_function_entry];
797797
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
798-
const TEMPLATE: AttributeTemplate = template!(List: &["prefix_nops = m, entry_nops = n"]);
798+
const TEMPLATE: AttributeTemplate =
799+
template!(List: &["prefix_nops = m, entry_nops = n, section = \"section\""]);
799800
const STABILITY: AttributeStability = unstable!(patchable_function_entry);
800801

801802
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
802803
let meta_item_list = cx.expect_list(args, cx.attr_span)?;
803804

804805
let mut prefix = None;
805806
let mut entry = None;
807+
let mut section = None;
806808

807809
if meta_item_list.len() == 0 {
808810
cx.adcx().expected_at_least_one_argument(meta_item_list.span);
809811
return None;
810812
}
811813

812-
let mut errored = false;
813-
814814
for item in meta_item_list.mixed() {
815815
let Some((ident, value)) = cx.expect_name_value(item, item.span(), None) else {
816-
continue;
816+
return None;
817817
};
818818

819819
let attrib_to_write = match ident.name {
820820
sym::prefix_nops => {
821821
// Duplicate prefixes are not allowed
822822
if prefix.is_some() {
823-
errored = true;
824823
cx.adcx().duplicate_key(ident.span, sym::prefix_nops);
825-
continue;
824+
return None;
826825
}
827826
&mut prefix
828827
}
829828
sym::entry_nops => {
830829
// Duplicate entries are not allowed
831830
if entry.is_some() {
832-
errored = true;
833831
cx.adcx().duplicate_key(ident.span, sym::entry_nops);
834-
continue;
832+
return None;
835833
}
836834
&mut entry
837835
}
836+
sym::section => {
837+
// Duplicate entries are not allowed
838+
if section.is_some() {
839+
cx.adcx().duplicate_key(ident.span, sym::section);
840+
return None;
841+
}
842+
// Only a string type value is allowed.
843+
let Some(value_str) = value.value_as_str() else {
844+
cx.adcx().expect_string_literal(value);
845+
return None;
846+
};
847+
// The section name does not allow null characters.
848+
if value_str.as_str().contains('\0') {
849+
cx.emit_err(NullOnSection { span: value.value_span });
850+
}
851+
// The section name is not allowed to be empty, LLVM does
852+
// not allow them.
853+
if value_str.is_empty() {
854+
cx.emit_err(EmptySection { span: value.value_span });
855+
}
856+
section = Some(value_str);
857+
// Integer parsing is not needed, process next item.
858+
continue;
859+
}
838860
_ => {
839-
errored = true;
840861
cx.adcx().expected_specific_argument(
841862
ident.span,
842863
&[sym::prefix_nops, sym::entry_nops],
843864
);
844-
continue;
865+
return None;
845866
}
846867
};
847868

848869
let rustc_ast::LitKind::Int(val, _) = value.value_as_lit().kind else {
849-
errored = true;
850870
cx.adcx().expected_integer_literal(value.value_span);
851-
continue;
871+
return None;
852872
};
853873

854874
let Ok(val) = val.get().try_into() else {
855-
errored = true;
856875
cx.adcx().expected_integer_literal_in_range(
857876
value.value_span,
858877
u8::MIN as isize,
859878
u8::MAX as isize,
860879
);
861-
continue;
880+
return None;
862881
};
863882

864883
*attrib_to_write = Some(val);
865884
}
866885

867-
if errored {
868-
None
869-
} else {
870-
Some(AttributeKind::PatchableFunctionEntry {
871-
prefix: prefix.unwrap_or(0),
872-
entry: entry.unwrap_or(0),
873-
})
874-
}
886+
Some(AttributeKind::PatchableFunctionEntry { prefix, entry, section })
875887
}
876888
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ pub(crate) struct EmptyExportName {
292292
pub span: Span,
293293
}
294294

295+
#[derive(Diagnostic)]
296+
#[diag("`section` may not be empty")]
297+
pub(crate) struct EmptySection {
298+
#[primary_span]
299+
pub span: Span,
300+
}
301+
295302
#[derive(Diagnostic)]
296303
#[diag("`export_name` may not contain null characters", code = E0648)]
297304
pub(crate) struct NullOnExport {
@@ -327,6 +334,13 @@ pub(crate) struct NullOnObjcSelector {
327334
pub span: Span,
328335
}
329336

337+
#[derive(Diagnostic)]
338+
#[diag("`section` may not contain null characters", code = E0648)]
339+
pub(crate) struct NullOnSection {
340+
#[primary_span]
341+
pub span: Span,
342+
}
343+
330344
#[derive(Diagnostic)]
331345
#[diag("`objc::class!` expected a string literal")]
332346
pub(crate) struct ObjcClassExpectedStringLiteral {

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
615615

616616
BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(..) => {
617617
match tcx.def_kind(self.mir_def) {
618-
DefKind::InlineConst => {
618+
DefKind::InlineConst if !tcx.is_type_system_inline_const(self.mir_def) => {
619619
// This is required for `AscribeUserType` canonical query, which will call
620620
// `type_of(inline_const_def_id)`. That `type_of` would inject erased lifetimes
621621
// into borrowck, which is ICE #78174.

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use gccjit::{LValue, RValue, ToRValue, Type};
22
use rustc_abi::Primitive::Pointer;
33
use rustc_abi::{self as abi, HasDataLayout};
44
use rustc_codegen_ssa::traits::{
5-
BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods,
5+
BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, PacMetadata,
6+
StaticCodegenMethods,
67
};
78
use rustc_middle::mir::Mutability;
89
use rustc_middle::mir::interpret::{GlobalAlloc, PointerArithmetic, Scalar};
@@ -241,7 +242,13 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
241242
None
242243
}
243244

244-
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> {
245+
fn scalar_to_backend_with_pac(
246+
&self,
247+
cv: Scalar,
248+
layout: abi::Scalar,
249+
ty: Type<'gcc>,
250+
_pac: Option<PacMetadata>,
251+
) -> RValue<'gcc> {
245252
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
246253
match cv {
247254
Scalar::Int(int) => {
@@ -290,7 +297,7 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
290297
}
291298
value
292299
}
293-
GlobalAlloc::Function { instance, .. } => self.get_fn_addr(instance),
300+
GlobalAlloc::Function { instance, .. } => self.get_fn_addr(instance, None),
294301
GlobalAlloc::VTable(ty, dyn_ty) => {
295302
let alloc = self
296303
.tcx

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use gccjit::{Block, CType, Context, Function, FunctionType, LValue, Location, RV
55
use rustc_abi::{Align, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
66
use rustc_codegen_ssa::base::wants_msvc_seh;
77
use rustc_codegen_ssa::errors as ssa_errors;
8-
use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, MiscCodegenMethods};
8+
use rustc_codegen_ssa::traits::{
9+
BackendTypes, BaseTypeCodegenMethods, MiscCodegenMethods, PacMetadata,
10+
};
911
use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, ToBaseN};
1012
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1113
use rustc_middle::mir::interpret::Allocation;
@@ -398,7 +400,7 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
398400
get_fn(self, instance)
399401
}
400402

401-
fn get_fn_addr(&self, instance: Instance<'tcx>) -> RValue<'gcc> {
403+
fn get_fn_addr(&self, instance: Instance<'tcx>, _pac: Option<PacMetadata>) -> RValue<'gcc> {
402404
let func_name = self.tcx.symbol_name(instance).name;
403405

404406
let func = if let Some(variable) = self.get_declared_value(func_name) {

0 commit comments

Comments
 (0)