Skip to content

Commit 4bd48b9

Browse files
committed
Auto merge of #158570 - jhpratt:rollup-8JjJt7Q, r=jhpratt
Rollup of 12 pull requests Successful merges: - #158073 (bootstrap: fix panic when repo path contains spaces by switching to CARGO_ENCODED_RUSTFLAGS) - #158169 (Fix debuginfo compression in bootstrap) - #158256 (Avoid parser panics bubbling out to proc macros) - #158375 (Support `DefKind::InlineConst` in `ConstKind::Unevaluated`) - #158417 (Avoid ICE when cfg_eval recovers no item from derive input) - #158556 (delegation: store child segment flag in `PathSegment`) - #158561 (Avoid building rustdoc for tests without doctests) - #158562 (Improve tracing of steps in bootstrap) - #157445 (Allow section override when using patchable-function-entries) - #158081 (trait-system: Recover deferred closure calls after errors) - #158327 (Move attribute and keyword docs from `std` to `core`) - #158468 (Include default-stability info in rustdoc JSON.)
2 parents 7dc2c16 + 1621f46 commit 4bd48b9

82 files changed

Lines changed: 1255 additions & 415 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_builtin_macros/src/cfg_eval.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,41 +107,42 @@ impl CfgEval<'_> {
107107
// our attribute target will correctly configure the tokens as well.
108108
let mut parser = Parser::new(&self.0.sess.psess, orig_tokens, None);
109109
parser.capture_cfg = true;
110-
let res: PResult<'_, Annotatable> = try {
111-
match annotatable {
112-
Annotatable::Item(_) => {
113-
let item =
114-
parser.parse_item(ForceCollect::Yes, AllowConstBlockItems::Yes)?.unwrap();
115-
Annotatable::Item(self.flat_map_item(item).pop().unwrap())
116-
}
110+
let res: PResult<'_, Option<Annotatable>> = try {
111+
match &annotatable {
112+
Annotatable::Item(_) => parser
113+
.parse_item(ForceCollect::Yes, AllowConstBlockItems::Yes)?
114+
.and_then(|item| self.flat_map_item(item).pop().map(Annotatable::Item)),
117115
Annotatable::AssocItem(_, ctxt) => {
118-
let item = parser.parse_trait_item(ForceCollect::Yes)?.unwrap().unwrap();
119-
Annotatable::AssocItem(
120-
self.flat_map_assoc_item(item, ctxt).pop().unwrap(),
121-
ctxt,
122-
)
116+
parser.parse_trait_item(ForceCollect::Yes)?.flatten().and_then(|item| {
117+
self.flat_map_assoc_item(item, *ctxt)
118+
.pop()
119+
.map(|item| Annotatable::AssocItem(item, *ctxt))
120+
})
123121
}
124122
Annotatable::ForeignItem(_) => {
125-
let item = parser.parse_foreign_item(ForceCollect::Yes)?.unwrap().unwrap();
126-
Annotatable::ForeignItem(self.flat_map_foreign_item(item).pop().unwrap())
127-
}
128-
Annotatable::Stmt(_) => {
129-
let stmt = parser
130-
.parse_stmt_without_recovery(false, ForceCollect::Yes, false)?
131-
.unwrap();
132-
Annotatable::Stmt(Box::new(self.flat_map_stmt(stmt).pop().unwrap()))
123+
parser.parse_foreign_item(ForceCollect::Yes)?.flatten().and_then(|item| {
124+
self.flat_map_foreign_item(item).pop().map(Annotatable::ForeignItem)
125+
})
133126
}
127+
Annotatable::Stmt(_) => parser
128+
.parse_stmt_without_recovery(false, ForceCollect::Yes, false)?
129+
.and_then(|stmt| {
130+
self.flat_map_stmt(stmt).pop().map(|stmt| Annotatable::Stmt(Box::new(stmt)))
131+
}),
134132
Annotatable::Expr(_) => {
135133
let mut expr = parser.parse_expr_force_collect()?;
136134
self.visit_expr(&mut expr);
137-
Annotatable::Expr(expr)
135+
Some(Annotatable::Expr(expr))
138136
}
139137
_ => unreachable!(),
140138
}
141139
};
142140

143141
match res {
144-
Ok(ann) => ann,
142+
Ok(Some(ann)) => ann,
143+
// Parser recovery may emit errors without reconstructing an annotatable.
144+
// Keep the original node so cfg-eval stays best-effort instead of ICEing.
145+
Ok(None) => annotatable,
145146
Err(err) => {
146147
err.emit();
147148
annotatable

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,26 @@ fn patchable_function_entry_attrs<'ll>(
8686
attr: Option<PatchableFunctionEntry>,
8787
) -> SmallVec<[&'ll Attribute; 2]> {
8888
let mut attrs = SmallVec::new();
89-
let patchable_spec = attr.unwrap_or_else(|| {
90-
PatchableFunctionEntry::from_config(sess.opts.unstable_opts.patchable_function_entry)
91-
});
92-
let entry = patchable_spec.entry();
93-
let prefix = patchable_spec.prefix();
89+
90+
let mut entry = sess.opts.unstable_opts.patchable_function_entry.entry();
91+
let mut prefix = sess.opts.unstable_opts.patchable_function_entry.prefix();
92+
let mut section = sess.opts.unstable_opts.patchable_function_entry.section();
93+
let section_sym;
94+
95+
// Apply attribute specified overrides, if any.
96+
if let Some(patchable_spec) = attr {
97+
if let Some(sym) = patchable_spec.section() {
98+
section_sym = sym;
99+
section = Some(section_sym.as_str());
100+
}
101+
// Override the nop counts if either is present. If only one is present, the
102+
// other count is implied to be 0.
103+
if patchable_spec.entry().is_some() || patchable_spec.prefix().is_some() {
104+
entry = patchable_spec.entry().unwrap_or(0);
105+
prefix = patchable_spec.prefix().unwrap_or(0);
106+
}
107+
}
108+
94109
if entry > 0 {
95110
attrs.push(llvm::CreateAttrStringValue(
96111
cx.llcx,
@@ -105,6 +120,13 @@ fn patchable_function_entry_attrs<'ll>(
105120
&format!("{}", prefix),
106121
));
107122
}
123+
if let Some(section) = section {
124+
attrs.push(llvm::CreateAttrStringValue(
125+
cx.llcx,
126+
"patchable-function-entry-section",
127+
section,
128+
));
129+
}
108130
attrs
109131
}
110132

0 commit comments

Comments
 (0)