Box the biggest ast::ItemKind variants
This commit is contained in:
parent
fee0d31397
commit
b87e1ecdf0
34 changed files with 309 additions and 204 deletions
|
@ -16,8 +16,8 @@ use crate::{
|
|||
use crate::{Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding};
|
||||
|
||||
use rustc_ast::visit::{self, AssocCtxt, Visitor};
|
||||
use rustc_ast::{self as ast, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId};
|
||||
use rustc_ast::{AssocItem, AssocItemKind, MetaItemKind, StmtKind};
|
||||
use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind};
|
||||
use rustc_ast::{Block, FnKind, ForeignItem, ForeignItemKind, ImplKind, Item, ItemKind, NodeId};
|
||||
use rustc_ast_lowering::ResolverAstLowering;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
@ -887,7 +887,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
}
|
||||
|
||||
// These items do not add names to modules.
|
||||
ItemKind::Impl { of_trait: Some(..), .. } => {
|
||||
ItemKind::Impl(box ImplKind { of_trait: Some(..), .. }) => {
|
||||
self.r.trait_impl_items.insert(local_def_id);
|
||||
}
|
||||
ItemKind::Impl { .. } | ItemKind::ForeignMod(..) | ItemKind::GlobalAsm(..) => {}
|
||||
|
@ -1371,7 +1371,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
AssocCtxt::Trait => {
|
||||
let (def_kind, ns) = match item.kind {
|
||||
AssocItemKind::Const(..) => (DefKind::AssocConst, ValueNS),
|
||||
AssocItemKind::Fn(_, ref sig, _, _) => {
|
||||
AssocItemKind::Fn(box FnKind(_, ref sig, _, _)) => {
|
||||
if sig.decl.has_self() {
|
||||
self.r.has_self.insert(def_id);
|
||||
}
|
||||
|
|
|
@ -493,8 +493,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) {
|
||||
match foreign_item.kind {
|
||||
ForeignItemKind::Fn(_, _, ref generics, _)
|
||||
| ForeignItemKind::TyAlias(_, ref generics, ..) => {
|
||||
ForeignItemKind::Fn(box FnKind(_, _, ref generics, _))
|
||||
| ForeignItemKind::TyAlias(box TyAliasKind(_, ref generics, ..)) => {
|
||||
self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
|
||||
visit::walk_foreign_item(this, foreign_item);
|
||||
});
|
||||
|
@ -938,7 +938,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
debug!("(resolving item) resolving {} ({:?})", name, item.kind);
|
||||
|
||||
match item.kind {
|
||||
ItemKind::TyAlias(_, ref generics, _, _) | ItemKind::Fn(_, _, ref generics, _) => {
|
||||
ItemKind::TyAlias(box TyAliasKind(_, ref generics, _, _))
|
||||
| ItemKind::Fn(box FnKind(_, _, ref generics, _)) => {
|
||||
self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
|
||||
visit::walk_item(this, item)
|
||||
});
|
||||
|
@ -950,17 +951,17 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
self.resolve_adt(item, generics);
|
||||
}
|
||||
|
||||
ItemKind::Impl {
|
||||
ItemKind::Impl(box ImplKind {
|
||||
ref generics,
|
||||
ref of_trait,
|
||||
ref self_ty,
|
||||
items: ref impl_items,
|
||||
..
|
||||
} => {
|
||||
}) => {
|
||||
self.resolve_implementation(generics, of_trait, &self_ty, item.id, impl_items);
|
||||
}
|
||||
|
||||
ItemKind::Trait(.., ref generics, ref bounds, ref trait_items) => {
|
||||
ItemKind::Trait(box TraitKind(.., ref generics, ref bounds, ref trait_items)) => {
|
||||
// Create a new rib for the trait-wide type parameters.
|
||||
self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
|
||||
let local_def_id = this.r.local_def_id(item.id).to_def_id();
|
||||
|
@ -995,10 +996,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
);
|
||||
}
|
||||
}
|
||||
AssocItemKind::Fn(_, _, generics, _) => {
|
||||
AssocItemKind::Fn(box FnKind(_, _, generics, _)) => {
|
||||
walk_assoc_item(this, generics, item);
|
||||
}
|
||||
AssocItemKind::TyAlias(_, generics, _, _) => {
|
||||
AssocItemKind::TyAlias(box TyAliasKind(_, generics, _, _)) => {
|
||||
walk_assoc_item(this, generics, item);
|
||||
}
|
||||
AssocItemKind::MacCall(_) => {
|
||||
|
@ -1306,7 +1307,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
},
|
||||
);
|
||||
}
|
||||
AssocItemKind::Fn(_, _, generics, _) => {
|
||||
AssocItemKind::Fn(box FnKind(.., generics, _)) => {
|
||||
// We also need a new scope for the impl item type parameters.
|
||||
this.with_generic_param_rib(
|
||||
generics,
|
||||
|
@ -1329,7 +1330,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
},
|
||||
);
|
||||
}
|
||||
AssocItemKind::TyAlias(_, generics, _, _) => {
|
||||
AssocItemKind::TyAlias(box TyAliasKind(
|
||||
_,
|
||||
generics,
|
||||
_,
|
||||
_,
|
||||
)) => {
|
||||
// We also need a new scope for the impl item type parameters.
|
||||
this.with_generic_param_rib(
|
||||
generics,
|
||||
|
|
|
@ -1109,7 +1109,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
if assoc_item.ident == ident {
|
||||
return Some(match &assoc_item.kind {
|
||||
ast::AssocItemKind::Const(..) => AssocSuggestion::AssocConst,
|
||||
ast::AssocItemKind::Fn(_, sig, ..) if sig.decl.has_self() => {
|
||||
ast::AssocItemKind::Fn(box ast::FnKind(_, sig, ..))
|
||||
if sig.decl.has_self() =>
|
||||
{
|
||||
AssocSuggestion::MethodWithSelf
|
||||
}
|
||||
ast::AssocItemKind::Fn(..) => AssocSuggestion::AssocFn,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//! Type-relative name resolution (methods, fields, associated items) happens in `librustc_typeck`.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(format_args_capture)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue