Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f76d77

Browse files
committed
Auto merge of #145039 - Zalathar:rollup-98v9fbg, r=Zalathar
Rollup of 20 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching) - #143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order) - #143808 (Port `#[should_panic]` to the new attribute parsing infrastructure ) - #143906 (Miri: non-deterministic floating point operations in `foreign_items`) - #143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps) - #144133 (Stabilize const TypeId::of) - #144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling) - #144473 (Address libunwind.a inconsistency issues in the bootstrap program) - #144659 (bootstrap: refactor mingw dist and fix gnullvm) - #144705 (compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled) - #144807 (Streamline config in bootstrap) - #144900 (Stabilize `unsigned_signed_diff` feature) - #144903 (Rename `begin_panic_handler` to `panic_handler`) - #144931 ([win][arm64ec] Fix msvc-wholearchive for Arm64EC) - #144974 (compiler-builtins subtree update) - #144997 (bump bootstrap compiler to 1.90 beta) - #145004 (Couple of minor cleanups) - #145009 (A couple small changes for rust-analyzer next-solver work) - #145014 (Revert "Preserve the .debug_gdb_scripts section") r? `@ghost` `@rustbot` modify labels: rollup
2 parents 61cb1e9 + a2974c3 commit 5f76d77

File tree

344 files changed

+4004
-3306
lines changed

Some content is hidden

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

344 files changed

+4004
-3306
lines changed

‎compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ast_passes_auto_generic = auto traits cannot have generic parameters
4040
4141
ast_passes_auto_items = auto traits cannot have associated items
4242
.label = {ast_passes_auto_items}
43-
.suggestion = remove these associated items
43+
.suggestion = remove the associated items
4444
4545
ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetime bounds
4646
.label = {ast_passes_auto_super_lifetime}

‎compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,19 +699,23 @@ impl<'a> AstValidator<'a> {
699699
}
700700
}
701701

702-
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
702+
fn deny_super_traits(&self, bounds: &GenericBounds, ident: Span) {
703703
if let [.., last] = &bounds[..] {
704-
let span = ident_span.shrink_to_hi().to(last.span());
705-
self.dcx().emit_err(errors::AutoTraitBounds { span, ident: ident_span });
704+
let span = bounds.iter().map(|b| b.span()).collect();
705+
let removal = ident.shrink_to_hi().to(last.span());
706+
self.dcx().emit_err(errors::AutoTraitBounds { span, removal, ident });
706707
}
707708
}
708709

709-
fn deny_where_clause(&self, where_clause: &WhereClause, ident_span: Span) {
710+
fn deny_where_clause(&self, where_clause: &WhereClause, ident: Span) {
710711
if !where_clause.predicates.is_empty() {
711712
// FIXME: The current diagnostic is misleading since it only talks about
712713
// super trait and lifetime bounds while we should just say "bounds".
713-
self.dcx()
714-
.emit_err(errors::AutoTraitBounds { span: where_clause.span, ident: ident_span });
714+
self.dcx().emit_err(errors::AutoTraitBounds {
715+
span: vec![where_clause.span],
716+
removal: where_clause.span,
717+
ident,
718+
});
715719
}
716720
}
717721

‎compiler/rustc_ast_passes/src/errors.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ pub(crate) struct ModuleNonAscii {
344344
#[diag(ast_passes_auto_generic, code = E0567)]
345345
pub(crate) struct AutoTraitGeneric {
346346
#[primary_span]
347-
#[suggestion(code = "", applicability = "machine-applicable")]
347+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
348348
pub span: Span,
349349
#[label]
350350
pub ident: Span,
@@ -354,8 +354,9 @@ pub(crate) struct AutoTraitGeneric {
354354
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
355355
pub(crate) struct AutoTraitBounds {
356356
#[primary_span]
357-
#[suggestion(code = "", applicability = "machine-applicable")]
358-
pub span: Span,
357+
pub span: Vec<Span>,
358+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
359+
pub removal: Span,
359360
#[label]
360361
pub ident: Span,
361362
}
@@ -365,7 +366,7 @@ pub(crate) struct AutoTraitBounds {
365366
pub(crate) struct AutoTraitItems {
366367
#[primary_span]
367368
pub spans: Vec<Span>,
368-
#[suggestion(code = "", applicability = "machine-applicable")]
369+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
369370
pub total: Span,
370371
#[label]
371372
pub ident: Span,

‎compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,55 @@ impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
4444
})
4545
}
4646
}
47+
48+
pub(crate) struct ShouldPanicParser;
49+
50+
impl<S: Stage> SingleAttributeParser<S> for ShouldPanicParser {
51+
const PATH: &[Symbol] = &[sym::should_panic];
52+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
53+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
54+
const TEMPLATE: AttributeTemplate =
55+
template!(Word, List: r#"expected = "reason""#, NameValueStr: "reason");
56+
57+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
58+
Some(AttributeKind::ShouldPanic {
59+
span: cx.attr_span,
60+
reason: match args {
61+
ArgParser::NoArgs => None,
62+
ArgParser::NameValue(name_value) => {
63+
let Some(str_value) = name_value.value_as_str() else {
64+
cx.expected_string_literal(
65+
name_value.value_span,
66+
Some(name_value.value_as_lit()),
67+
);
68+
return None;
69+
};
70+
Some(str_value)
71+
}
72+
ArgParser::List(list) => {
73+
let Some(single) = list.single() else {
74+
cx.expected_single_argument(list.span);
75+
return None;
76+
};
77+
let Some(single) = single.meta_item() else {
78+
cx.expected_name_value(single.span(), Some(sym::expected));
79+
return None;
80+
};
81+
if !single.path().word_is(sym::expected) {
82+
cx.expected_specific_argument_strings(list.span, vec!["expected"]);
83+
return None;
84+
}
85+
let Some(nv) = single.args().name_value() else {
86+
cx.expected_name_value(single.span(), Some(sym::expected));
87+
return None;
88+
};
89+
let Some(expected) = nv.value_as_str() else {
90+
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
91+
return None;
92+
};
93+
Some(expected)
94+
}
95+
},
96+
})
97+
}
98+
}

‎compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use crate::attributes::semantics::MayDangleParser;
5050
use crate::attributes::stability::{
5151
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
5252
};
53-
use crate::attributes::test_attrs::IgnoreParser;
53+
use crate::attributes::test_attrs::{IgnoreParser,ShouldPanicParser};
5454
use crate::attributes::traits::{
5555
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
5656
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
@@ -174,6 +174,7 @@ attribute_parsers!(
174174
Single<RustcLayoutScalarValidRangeEnd>,
175175
Single<RustcLayoutScalarValidRangeStart>,
176176
Single<RustcObjectLifetimeDefaultParser>,
177+
Single<ShouldPanicParser>,
177178
Single<SkipDuringMethodDispatchParser>,
178179
Single<TransparencyParser>,
179180
Single<WithoutArgs<AllowIncoherentImplParser>>,

‎compiler/rustc_builtin_macros/src/test.rs

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ use std::assert_matches::assert_matches;
55
use std::iter;
66

77
use rustc_ast::ptr::P;
8-
use rustc_ast::{self as ast, GenericParamKind, attr, join_path_idents};
8+
use rustc_ast::{self as ast, GenericParamKind, HasNodeId,attr, join_path_idents};
99
use rustc_ast_pretty::pprust;
10+
use rustc_attr_parsing::AttributeParser;
1011
use rustc_errors::{Applicability, Diag, Level};
1112
use rustc_expand::base::*;
13+
use rustc_hir::Attribute;
14+
use rustc_hir::attrs::AttributeKind;
1215
use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Ident, Span, Symbol, sym};
1316
use thin_vec::{ThinVec, thin_vec};
1417
use tracing::debug;
@@ -473,39 +476,19 @@ fn should_ignore_message(i: &ast::Item) -> Option<Symbol> {
473476
}
474477

475478
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
476-
match attr::find_by_name(&i.attrs, sym::should_panic) {
477-
Some(attr) => {
478-
match attr.meta_item_list() {
479-
// Handle #[should_panic(expected = "foo")]
480-
Some(list) => {
481-
let msg = list
482-
.iter()
483-
.find(|mi| mi.has_name(sym::expected))
484-
.and_then(|mi| mi.meta_item())
485-
.and_then(|mi| mi.value_str());
486-
if list.len() != 1 || msg.is_none() {
487-
cx.dcx()
488-
.struct_span_warn(
489-
attr.span,
490-
"argument must be of the form: \
491-
`expected = \"error message\"`",
492-
)
493-
.with_note(
494-
"errors in this attribute were erroneously \
495-
allowed and will become a hard error in a \
496-
future release",
497-
)
498-
.emit();
499-
ShouldPanic::Yes(None)
500-
} else {
501-
ShouldPanic::Yes(msg)
502-
}
503-
}
504-
// Handle #[should_panic] and #[should_panic = "expected"]
505-
None => ShouldPanic::Yes(attr.value_str()),
506-
}
507-
}
508-
None => ShouldPanic::No,
479+
if let Some(Attribute::Parsed(AttributeKind::ShouldPanic { reason, .. })) =
480+
AttributeParser::parse_limited(
481+
cx.sess,
482+
&i.attrs,
483+
sym::should_panic,
484+
i.span,
485+
i.node_id(),
486+
None,
487+
)
488+
{
489+
ShouldPanic::Yes(reason)
490+
} else {
491+
ShouldPanic::No
509492
}
510493
}
511494

‎compiler/rustc_codegen_gcc/src/debuginfo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
254254
// TODO(antoyo): implement.
255255
}
256256

257-
fn debuginfo_finalize(&mut self) {
258-
// TODO: emit section `.debug_gdb_scripts`.
257+
fn debuginfo_finalize(&self) {
259258
self.context.set_debug_info(true)
260259
}
261260

‎compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ pub(crate) fn codegen(
862862
.generic_activity_with_arg("LLVM_module_codegen_embed_bitcode", &*module.name);
863863
let thin_bc =
864864
module.thin_lto_buffer.as_deref().expect("cannot find embedded bitcode");
865-
embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline,&thin_bc);
865+
embed_bitcode(cgcx, llcx, llmod, &thin_bc);
866866
}
867867
}
868868

@@ -1058,40 +1058,38 @@ fn embed_bitcode(
10581058
cgcx: &CodegenContext<LlvmCodegenBackend>,
10591059
llcx: &llvm::Context,
10601060
llmod: &llvm::Module,
1061-
cmdline: &str,
10621061
bitcode: &[u8],
10631062
) {
10641063
// We're adding custom sections to the output object file, but we definitely
10651064
// do not want these custom sections to make their way into the final linked
1066-
// executable. The purpose of these custom sections is for tooling
1067-
// surrounding object files to work with the LLVM IR, if necessary. For
1068-
// example rustc's own LTO will look for LLVM IR inside of the object file
1069-
// in these sections by default.
1065+
// executable. The purpose of this custom section is for tooling surrounding
1066+
// object files to work with the LLVM IR, if necessary. For example rustc's
1067+
// own LTO will look for LLVM IR inside of the object file in this section
1068+
// by default.
10701069
//
10711070
// To handle this is a bit different depending on the object file format
10721071
// used by the backend, broken down into a few different categories:
10731072
//
10741073
// * Mach-O - this is for macOS. Inspecting the source code for the native
1075-
// linker here shows that the `.llvmbc` and `.llvmcmd` sections are
1076-
// automatically skipped by the linker. In that case there's nothing extra
1077-
// that we need to do here.
1074+
// linker here shows that the `.llvmbc` section is automatically skipped
1075+
// by the linker. In that case there's nothing extra that we need to do
1076+
// here.
10781077
//
1079-
// * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` and
1080-
// `.llvmcmd` sections, so there's nothing extra we need to do.
1078+
// * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` section,
1079+
// so there's nothing extra we need to do.
10811080
//
1082-
// * COFF - if we don't do anything the linker will by default copy all
1083-
// these sections to the output artifact, not what we want! To subvert
1084-
// this we want to flag the sections we inserted here as
1085-
// `IMAGE_SCN_LNK_REMOVE`.
1081+
// * COFF - if we don't do anything the linker will by default copy this
1082+
// section to the output artifact, not what we want! To subvert this we
1083+
// want to flag the section we inserted here as `IMAGE_SCN_LNK_REMOVE`.
10861084
//
1087-
// * ELF - this is very similar to COFF above. One difference is that these
1088-
// sections are removed from the output linked artifact when
1089-
// `--gc-sections` is passed, which we pass by default. If that flag isn't
1090-
// passed though then these sections will show up in the final output.
1091-
// Additionally the flag that we need to set here is `SHF_EXCLUDE`.
1085+
// * ELF - this is very similar to COFF above. One difference is that this
1086+
// section is removed from the output linked artifact when `--gc-sections`
1087+
// is passed, which we pass by default. If that flag isn't passed through
1088+
// then this section will show up in the final output. Additionally the
1089+
// flag that we need to set here is `SHF_EXCLUDE`.
10921090
//
1093-
// * XCOFF - AIX linker ignores content in .ipa and .info if no auxiliary
1094-
// symbol associated with these sections.
1091+
// * XCOFF - AIX linker ignores content in .ipa if no auxiliary symbol
1092+
// associated with this section.
10951093
//
10961094
// Unfortunately, LLVM provides no way to set custom section flags. For ELF
10971095
// and COFF we emit the sections using module level inline assembly for that
@@ -1110,26 +1108,11 @@ fn embed_bitcode(
11101108
llvm::set_section(llglobal, bitcode_section_name(cgcx));
11111109
llvm::set_linkage(llglobal, llvm::Linkage::PrivateLinkage);
11121110
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
1113-
1114-
let llconst = common::bytes_in_context(llcx, cmdline.as_bytes());
1115-
let llglobal = llvm::add_global(llmod, common::val_ty(llconst), c"rustc.embedded.cmdline");
1116-
llvm::set_initializer(llglobal, llconst);
1117-
let section = if cgcx.target_is_like_darwin {
1118-
c"__LLVM,__cmdline"
1119-
} else if cgcx.target_is_like_aix {
1120-
c".info"
1121-
} else {
1122-
c".llvmcmd"
1123-
};
1124-
llvm::set_section(llglobal, section);
1125-
llvm::set_linkage(llglobal, llvm::Linkage::PrivateLinkage);
11261111
} else {
11271112
// We need custom section flags, so emit module-level inline assembly.
11281113
let section_flags = if cgcx.is_pe_coff { "n" } else { "e" };
11291114
let asm = create_section_with_flags_asm(".llvmbc", section_flags, bitcode);
11301115
llvm::append_module_inline_asm(llmod, &asm);
1131-
let asm = create_section_with_flags_asm(".llvmcmd", section_flags, cmdline.as_bytes());
1132-
llvm::append_module_inline_asm(llmod, &asm);
11331116
}
11341117
}
11351118

‎compiler/rustc_codegen_llvm/src/base.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,11 @@ pub(crate) fn compile_codegen_unit(
109109
}
110110

111111
// Finalize code coverage by injecting the coverage map. Note, the coverage map will
112-
// also be added to the `llvm.compiler.used` variable, created below.
112+
// also be added to the `llvm.compiler.used` variable, created next.
113113
if cx.sess().instrument_coverage() {
114114
cx.coverageinfo_finalize();
115115
}
116116

117-
// Finalize debuginfo. This adds to `llvm.used`, created below.
118-
if cx.sess().opts.debuginfo != DebugInfo::None {
119-
cx.debuginfo_finalize();
120-
}
121-
122117
// Create the llvm.used and llvm.compiler.used variables.
123118
if !cx.used_statics.is_empty() {
124119
cx.create_used_variable_impl(c"llvm.used", &cx.used_statics);
@@ -135,6 +130,11 @@ pub(crate) fn compile_codegen_unit(
135130
llvm::LLVMDeleteGlobal(old_g);
136131
}
137132
}
133+
134+
// Finalize debuginfo
135+
if cx.sess().opts.debuginfo != DebugInfo::None {
136+
cx.debuginfo_finalize();
137+
}
138138
}
139139

140140
ModuleCodegen::new_regular(cgu_name.to_string(), llvm_module)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /