Skip to content

Commit a4fe507

Browse files
Auto merge of #145034 - Zalathar:rollup-5a779oe, r=<try>
Rollup of 21 pull requests try-job: test-various try-job: dist-ohos-x86_64
2 parents 6bcdcc7 + 79e429a commit a4fe507

File tree

360 files changed

+4488
-4036
lines changed

Some content is hidden

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

360 files changed

+4488
-4036
lines changed

Cargo.lock

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,12 @@ version = "1.0.10"
12031203
source = "registry+https://github.com/rust-lang/crates.io-index"
12041204
checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921"
12051205

1206+
[[package]]
1207+
name = "dyn-clone"
1208+
version = "1.0.19"
1209+
source = "registry+https://github.com/rust-lang/crates.io-index"
1210+
checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005"
1211+
12061212
[[package]]
12071213
name = "either"
12081214
version = "1.15.0"
@@ -3196,6 +3202,26 @@ dependencies = [
31963202
"thiserror 2.0.12",
31973203
]
31983204

3205+
[[package]]
3206+
name = "ref-cast"
3207+
version = "1.0.24"
3208+
source = "registry+https://github.com/rust-lang/crates.io-index"
3209+
checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf"
3210+
dependencies = [
3211+
"ref-cast-impl",
3212+
]
3213+
3214+
[[package]]
3215+
name = "ref-cast-impl"
3216+
version = "1.0.24"
3217+
source = "registry+https://github.com/rust-lang/crates.io-index"
3218+
checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7"
3219+
dependencies = [
3220+
"proc-macro2",
3221+
"quote",
3222+
"syn 2.0.104",
3223+
]
3224+
31993225
[[package]]
32003226
name = "regex"
32013227
version = "1.11.1"
@@ -4650,6 +4676,7 @@ dependencies = [
46504676
"rustc_macros",
46514677
"rustc_serialize",
46524678
"rustc_span",
4679+
"schemars",
46534680
"serde",
46544681
"serde_derive",
46554682
"serde_json",
@@ -4964,6 +4991,31 @@ dependencies = [
49644991
"windows-sys 0.59.0",
49654992
]
49664993

4994+
[[package]]
4995+
name = "schemars"
4996+
version = "1.0.4"
4997+
source = "registry+https://github.com/rust-lang/crates.io-index"
4998+
checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
4999+
dependencies = [
5000+
"dyn-clone",
5001+
"ref-cast",
5002+
"schemars_derive",
5003+
"serde",
5004+
"serde_json",
5005+
]
5006+
5007+
[[package]]
5008+
name = "schemars_derive"
5009+
version = "1.0.4"
5010+
source = "registry+https://github.com/rust-lang/crates.io-index"
5011+
checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
5012+
dependencies = [
5013+
"proc-macro2",
5014+
"quote",
5015+
"serde_derive_internals",
5016+
"syn 2.0.104",
5017+
]
5018+
49675019
[[package]]
49685020
name = "scoped-tls"
49695021
version = "1.0.1"
@@ -5038,6 +5090,17 @@ dependencies = [
50385090
"syn 2.0.104",
50395091
]
50405092

5093+
[[package]]
5094+
name = "serde_derive_internals"
5095+
version = "0.29.1"
5096+
source = "registry+https://github.com/rust-lang/crates.io-index"
5097+
checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711"
5098+
dependencies = [
5099+
"proc-macro2",
5100+
"quote",
5101+
"syn 2.0.104",
5102+
]
5103+
50415104
[[package]]
50425105
name = "serde_json"
50435106
version = "1.0.142"

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

0 commit comments

Comments
 (0)