Skip to content

Commit 7bb7280

Browse files
committed
Auto merge of #152810 - JonathanBrouwer:rollup-3OFTrE3, r=<try>
Rollup of 18 pull requests try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1 try-job: test-various try-job: armhf-gnu try-job: aarch64-apple try-job: x86_64-gnu-llvm-20-3 try-job: dist-various-2
2 parents c043085 + d56ef16 commit 7bb7280

File tree

80 files changed

+1738
-339
lines changed

Some content is hidden

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

80 files changed

+1738
-339
lines changed

compiler/rustc_abi/src/layout/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ rustc_index::newtype_index! {
3333
/// `b` is `FieldIdx(1)` in `VariantIdx(0)`,
3434
/// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and
3535
/// `f` is `FieldIdx(1)` in `VariantIdx(0)`.
36-
#[derive(HashStable_Generic)]
36+
#[stable_hash_generic]
3737
#[encodable]
3838
#[orderable]
3939
pub struct FieldIdx {}
@@ -57,7 +57,7 @@ rustc_index::newtype_index! {
5757
///
5858
/// `struct`s, `tuples`, and `unions`s are considered to have a single variant
5959
/// with variant index zero, aka [`FIRST_VARIANT`].
60-
#[derive(HashStable_Generic)]
60+
#[stable_hash_generic]
6161
#[encodable]
6262
#[orderable]
6363
pub struct VariantIdx {

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,13 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
522522
return self.parser.dcx().create_err(err);
523523
}
524524

525+
if let ShouldEmit::ErrorsAndLints { recovery: Recovery::Forbidden } = self.should_emit {
526+
// Do not attempt to suggest anything in `Recovery::Forbidden` mode.
527+
// Malformed diagnostic-attr arguments that start with an `if` expression can lead to
528+
// an ICE (https://github.com/rust-lang/rust/issues/152744), because callers may cancel the `InvalidMetaItem` error.
529+
return self.parser.dcx().create_err(err);
530+
}
531+
525532
// Suggest quoting idents, e.g. in `#[cfg(key = value)]`. We don't use `Token::ident` and
526533
// don't `uninterpolate` the token to avoid suggesting anything butchered or questionable
527534
// when macro metavariables are involved.

compiler/rustc_builtin_macros/src/deriving/default.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn default_struct_substructure(
6767
cx: &ExtCtxt<'_>,
6868
trait_span: Span,
6969
substr: &Substructure<'_>,
70-
summary: &StaticFields,
70+
summary: &StaticFields<'_>,
7171
) -> BlockOrExpr {
7272
let expr = match summary {
7373
Unnamed(_, IsTuple::No) => cx.expr_ident(trait_span, substr.type_ident),
@@ -78,16 +78,16 @@ fn default_struct_substructure(
7878
Named(fields) => {
7979
let default_fields = fields
8080
.iter()
81-
.map(|(ident, span, default_val)| {
81+
.map(|&(ident, span, default_val)| {
8282
let value = match default_val {
8383
// We use `Default::default()`.
84-
None => default_call(cx, *span),
84+
None => default_call(cx, span),
8585
// We use the field default const expression.
8686
Some(val) => {
8787
cx.expr(val.value.span, ast::ExprKind::ConstBlock(val.clone()))
8888
}
8989
};
90-
cx.field_imm(*span, *ident, value)
90+
cx.field_imm(span, ident, value)
9191
})
9292
.collect();
9393
cx.expr_struct_ident(trait_span, substr.type_ident, default_fields)

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ pub(crate) enum IsTuple {
303303
}
304304

305305
/// Fields for a static method
306-
pub(crate) enum StaticFields {
306+
pub(crate) enum StaticFields<'a> {
307307
/// Tuple and unit structs/enum variants like this.
308308
Unnamed(Vec<Span>, IsTuple),
309309
/// Normal structs/struct variants.
310-
Named(Vec<(Ident, Span, Option<AnonConst>)>),
310+
Named(Vec<(Ident, Span, Option<&'a AnonConst>)>),
311311
}
312312

313313
/// A summary of the possible sets of fields.
@@ -331,7 +331,7 @@ pub(crate) enum SubstructureFields<'a> {
331331
EnumDiscr(FieldInfo, Option<Box<Expr>>),
332332

333333
/// A static method where `Self` is a struct.
334-
StaticStruct(&'a ast::VariantData, StaticFields),
334+
StaticStruct(&'a ast::VariantData, StaticFields<'a>),
335335

336336
/// A static method where `Self` is an enum.
337337
StaticEnum(&'a ast::EnumDef),
@@ -596,7 +596,7 @@ impl<'a> TraitDef<'a> {
596596
cx: &ExtCtxt<'_>,
597597
type_ident: Ident,
598598
generics: &Generics,
599-
field_tys: Vec<Box<ast::Ty>>,
599+
field_tys: Vec<&ast::Ty>,
600600
methods: Vec<Box<ast::AssocItem>>,
601601
is_packed: bool,
602602
) -> Box<ast::Item> {
@@ -870,8 +870,7 @@ impl<'a> TraitDef<'a> {
870870
from_scratch: bool,
871871
is_packed: bool,
872872
) -> Box<ast::Item> {
873-
let field_tys: Vec<Box<ast::Ty>> =
874-
struct_def.fields().iter().map(|field| field.ty.clone()).collect();
873+
let field_tys = Vec::from_iter(struct_def.fields().iter().map(|field| &*field.ty));
875874

876875
let methods = self
877876
.methods
@@ -923,11 +922,13 @@ impl<'a> TraitDef<'a> {
923922
generics: &Generics,
924923
from_scratch: bool,
925924
) -> Box<ast::Item> {
926-
let mut field_tys = Vec::new();
927-
928-
for variant in &enum_def.variants {
929-
field_tys.extend(variant.data.fields().iter().map(|field| field.ty.clone()));
930-
}
925+
let field_tys = Vec::from_iter(
926+
enum_def
927+
.variants
928+
.iter()
929+
.flat_map(|variant| variant.data.fields())
930+
.map(|field| &*field.ty),
931+
);
931932

932933
let methods = self
933934
.methods
@@ -1160,8 +1161,8 @@ impl<'a> MethodDef<'a> {
11601161
fn expand_static_struct_method_body(
11611162
&self,
11621163
cx: &ExtCtxt<'_>,
1163-
trait_: &TraitDef<'_>,
1164-
struct_def: &VariantData,
1164+
trait_: &TraitDef<'a>,
1165+
struct_def: &'a VariantData,
11651166
type_ident: Ident,
11661167
nonselflike_args: &[Box<Expr>],
11671168
) -> BlockOrExpr {
@@ -1480,13 +1481,13 @@ impl<'a> MethodDef<'a> {
14801481

14811482
// general helper methods.
14821483
impl<'a> TraitDef<'a> {
1483-
fn summarise_struct(&self, cx: &ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
1484+
fn summarise_struct(&self, cx: &ExtCtxt<'_>, struct_def: &'a VariantData) -> StaticFields<'a> {
14841485
let mut named_idents = Vec::new();
14851486
let mut just_spans = Vec::new();
14861487
for field in struct_def.fields() {
14871488
let sp = field.span.with_ctxt(self.span.ctxt());
14881489
match field.ident {
1489-
Some(ident) => named_idents.push((ident, sp, field.default.clone())),
1490+
Some(ident) => named_idents.push((ident, sp, field.default.as_ref())),
14901491
_ => just_spans.push(sp),
14911492
}
14921493
}

0 commit comments

Comments
 (0)