Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3694a6b

Browse files
committed
Auto merge of rust-lang#119170 - matthiaskrgr:rollup-nllgdf2, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#119135 (Fix crash due to `CrateItem::kind()` not handling constructors) - rust-lang#119141 (Add method to get instance instantiation arguments) - rust-lang#119145 (Give `VariantData::Struct` named fields, to clairfy `recovered`.) - rust-lang#119167 (E0761: module directory has .rs suffix) - rust-lang#119168 (resolve: Stop feeding visibilities for import list stems) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5ac4c8a + c36bb5d commit 3694a6b

File tree

30 files changed

+182
-45
lines changed

30 files changed

+182
-45
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,11 @@ pub enum VariantData {
27882788
/// Struct variant.
27892789
///
27902790
/// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
2791-
Struct(ThinVec<FieldDef>, bool),
2791+
Struct {
2792+
fields: ThinVec<FieldDef>,
2793+
// FIXME: investigate making this a `Option<ErrorGuaranteed>`
2794+
recovered: bool,
2795+
},
27922796
/// Tuple variant.
27932797
///
27942798
/// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
@@ -2803,15 +2807,15 @@ impl VariantData {
28032807
/// Return the fields of this variant.
28042808
pub fn fields(&self) -> &[FieldDef] {
28052809
match self {
2806-
VariantData::Struct(fields, ..) | VariantData::Tuple(fields, _) => fields,
2810+
VariantData::Struct { fields, .. } | VariantData::Tuple(fields, _) => fields,
28072811
_ => &[],
28082812
}
28092813
}
28102814

28112815
/// Return the `NodeId` of this variant's constructor, if it has one.
28122816
pub fn ctor_node_id(&self) -> Option<NodeId> {
28132817
match *self {
2814-
VariantData::Struct(..) => None,
2818+
VariantData::Struct { .. } => None,
28152819
VariantData::Tuple(_, id) | VariantData::Unit(id) => Some(id),
28162820
}
28172821
}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ pub fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis:
976976

977977
pub fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T) {
978978
match vdata {
979-
VariantData::Struct(fields, ..) => {
979+
VariantData::Struct { fields, .. } => {
980980
fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
981981
}
982982
VariantData::Tuple(fields, id) => {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
661661
vdata: &VariantData,
662662
) -> hir::VariantData<'hir> {
663663
match vdata {
664-
VariantData::Struct(fields, recovered) => hir::VariantData::Struct(
665-
self.arena
664+
VariantData::Struct { fields, recovered } => hir::VariantData::Struct {
665+
fields: self
666+
.arena
666667
.alloc_from_iter(fields.iter().enumerate().map(|f| self.lower_field_def(f))),
667-
*recovered,
668-
),
668+
recovered: *recovered,
669+
},
669670
VariantData::Tuple(fields, id) => {
670671
let ctor_id = self.lower_node_id(*id);
671672
self.alias_attrs(ctor_id, parent_id);

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10001000
}
10011001
}
10021002
ItemKind::Struct(vdata, generics) => match vdata {
1003-
VariantData::Struct(fields, ..) => {
1003+
VariantData::Struct { fields, .. } => {
10041004
self.visit_vis(&item.vis);
10051005
self.visit_ident(item.ident);
10061006
self.visit_generics(generics);
@@ -1016,7 +1016,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10161016
self.dcx().emit_err(errors::FieldlessUnion { span: item.span });
10171017
}
10181018
match vdata {
1019-
VariantData::Struct(fields, ..) => {
1019+
VariantData::Struct { fields, .. } => {
10201020
self.visit_vis(&item.vis);
10211021
self.visit_ident(item.ident);
10221022
self.visit_generics(generics);

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ impl<'a> State<'a> {
500500
self.end();
501501
self.end(); // Close the outer-box.
502502
}
503-
ast::VariantData::Struct(fields, ..) => {
503+
ast::VariantData::Struct { fields, .. } => {
504504
self.print_where_clause(&generics.where_clause);
505505
self.print_record_struct_body(fields, span);
506506
}

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn cs_clone(
188188
}
189189

190190
let expr = match *vdata {
191-
VariantData::Struct(..) => {
191+
VariantData::Struct { .. } => {
192192
let fields = all_fields
193193
.iter()
194194
.map(|field| {

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
7171
(false, 0)
7272
}
7373
ast::VariantData::Tuple(..) => (false, 1),
74-
ast::VariantData::Struct(..) => (true, 2),
74+
ast::VariantData::Struct { .. } => (true, 2),
7575
};
7676

7777
// The number of fields that can be handled without an array.
@@ -226,7 +226,7 @@ fn show_fieldless_enum(
226226
debug_assert!(fields.is_empty());
227227
cx.pat_tuple_struct(span, variant_path, ThinVec::new())
228228
}
229-
ast::VariantData::Struct(fields, _) => {
229+
ast::VariantData::Struct { fields, .. } => {
230230
debug_assert!(fields.is_empty());
231231
cx.pat_struct(span, variant_path, ThinVec::new())
232232
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ impl<'a> TraitDef<'a> {
14851485

14861486
let struct_path = struct_path.clone();
14871487
match *struct_def {
1488-
VariantData::Struct(..) => {
1488+
VariantData::Struct { .. } => {
14891489
let field_pats = pieces_iter
14901490
.map(|(sp, ident, pat)| {
14911491
if ident.is_none() {

compiler/rustc_error_codes/src/error_codes/E0761.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn foo() {}
1515
1616
mod ambiguous_module; // error: file for module `ambiguous_module`
1717
// found at both ambiguous_module.rs and
18-
// ambiguous_module.rs/mod.rs
18+
// ambiguous_module/mod.rs
1919
```
2020

2121
Please remove this ambiguity by deleting/renaming one of the candidate files.

compiler/rustc_expand/src/placeholders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub fn placeholder(
174174
}]),
175175
AstFragmentKind::Variants => AstFragment::Variants(smallvec![ast::Variant {
176176
attrs: Default::default(),
177-
data: ast::VariantData::Struct(Default::default(), false),
177+
data: ast::VariantData::Struct { fields: Default::default(), recovered: false },
178178
disr_expr: None,
179179
id,
180180
ident,

0 commit comments

Comments
 (0)