Skip to content

Commit 443c0d8

Browse files
committed
Box TraitAliasKind
1 parent f7a6147 commit 443c0d8

File tree

8 files changed

+21
-14
lines changed

8 files changed

+21
-14
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,6 +2697,9 @@ pub struct StructUnionKind(pub VariantData, pub Generics);
26972697
#[derive(Clone, Encodable, Decodable, Debug)]
26982698
pub struct EnumKind(pub EnumDef, pub Generics);
26992699

2700+
#[derive(Clone, Encodable, Decodable, Debug)]
2701+
pub struct TraitAliasKind(pub Generics, pub GenericBounds);
2702+
27002703
#[derive(Clone, Encodable, Decodable, Debug)]
27012704
pub enum ItemKind {
27022705
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
@@ -2752,7 +2755,7 @@ pub enum ItemKind {
27522755
/// Trait alias
27532756
///
27542757
/// E.g., `trait Foo = Bar + Quux;`.
2755-
TraitAlias(Generics, GenericBounds),
2758+
TraitAlias(Box<TraitAliasKind>),
27562759
/// An implementation.
27572760
///
27582761
/// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
@@ -2767,7 +2770,7 @@ pub enum ItemKind {
27672770
}
27682771

27692772
#[cfg(target_arch = "x86_64")]
2770-
rustc_data_structures::static_assert_size!(ItemKind, 104);
2773+
rustc_data_structures::static_assert_size!(ItemKind, 72);
27712774

27722775
impl ItemKind {
27732776
pub fn article(&self) -> &str {
@@ -2809,7 +2812,7 @@ impl ItemKind {
28092812
| Self::Struct(box StructUnionKind(_, generics))
28102813
| Self::Union(box StructUnionKind(_, generics))
28112814
| Self::Trait(box TraitKind(_, _, generics, ..))
2812-
| Self::TraitAlias(generics, _)
2815+
| Self::TraitAlias(box TraitAliasKind(generics, _))
28132816
| Self::Impl(box ImplKind { generics, .. }) => Some(generics),
28142817
_ => None,
28152818
}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
955955
visit_bounds(bounds, vis);
956956
items.flat_map_in_place(|item| vis.flat_map_trait_item(item));
957957
}
958-
ItemKind::TraitAlias(generics, bounds) => {
958+
ItemKind::TraitAlias(box TraitAliasKind(generics, bounds)) => {
959959
vis.visit_generics(generics);
960960
visit_bounds(bounds, vis);
961961
}

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
337337
walk_list!(visitor, visit_param_bound, bounds);
338338
walk_list!(visitor, visit_assoc_item, items, AssocCtxt::Trait);
339339
}
340-
ItemKind::TraitAlias(ref generics, ref bounds) => {
340+
ItemKind::TraitAlias(box TraitAliasKind(ref generics, ref bounds)) => {
341341
visitor.visit_generics(generics);
342342
walk_list!(visitor, visit_param_bound, bounds);
343343
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
469469
items,
470470
)
471471
}
472-
ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemKind::TraitAlias(
473-
self.lower_generics(generics, ImplTraitContext::disallowed()),
474-
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
475-
),
472+
ItemKind::TraitAlias(box TraitAliasKind(ref generics, ref bounds)) => {
473+
hir::ItemKind::TraitAlias(
474+
self.lower_generics(generics, ImplTraitContext::disallowed()),
475+
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
476+
)
477+
}
476478
ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
477479
panic!("`TyMac` should have been expanded by now")
478480
}

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ impl<'a> State<'a> {
12671267
}
12681268
self.bclose(item.span);
12691269
}
1270-
ast::ItemKind::TraitAlias(ref generics, ref bounds) => {
1270+
ast::ItemKind::TraitAlias(box ast::TraitAliasKind(ref generics, ref bounds)) => {
12711271
self.head("");
12721272
self.print_visibility(&item.vis);
12731273
self.word_nbsp("trait");

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl<'a> Parser<'a> {
713713

714714
self.sess.gated_spans.gate(sym::trait_alias, whole_span);
715715

716-
Ok((ident, ItemKind::TraitAlias(tps, bounds)))
716+
Ok((ident, ItemKind::TraitAlias(box TraitAliasKind(tps, bounds))))
717717
} else {
718718
// It's a normal trait.
719719
tps.where_clause = self.parse_where_clause()?;

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
10121012
});
10131013
}
10141014

1015-
ItemKind::TraitAlias(ref generics, ref bounds) => {
1015+
ItemKind::TraitAlias(box TraitAliasKind(ref generics, ref bounds)) => {
10161016
// Create a new rib for the trait-wide type parameters.
10171017
self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
10181018
let local_def_id = this.r.local_def_id(item.id).to_def_id();

src/tools/clippy/clippy_lints/src/utils/ast_utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,10 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
267267
&& eq_generics(lg, rg)
268268
&& over(lb, rb, |l, r| eq_generic_bound(l, r))
269269
&& over(li, ri, |l, r| eq_item(l, r, eq_assoc_item_kind))
270-
},
271-
(TraitAlias(lg, lb), TraitAlias(rg, rb)) => eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r)),
270+
}
271+
(TraitAlias(box TraitAliasKind(lg, lb)), TraitAlias(box TraitAliasKind(rg, rb))) => {
272+
eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r))
273+
}
272274
(
273275
Impl(box ImplKind {
274276
unsafety: lu,

0 commit comments

Comments
 (0)