Box the biggest ast::ItemKind variants
This commit is contained in:
parent
fee0d31397
commit
b87e1ecdf0
34 changed files with 309 additions and 204 deletions
|
@ -920,7 +920,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
|
||||
match item.kind {
|
||||
ItemKind::Impl {
|
||||
ItemKind::Impl(box ImplKind {
|
||||
unsafety,
|
||||
polarity,
|
||||
defaultness: _,
|
||||
|
@ -929,7 +929,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
of_trait: Some(ref t),
|
||||
ref self_ty,
|
||||
items: _,
|
||||
} => {
|
||||
}) => {
|
||||
self.with_in_trait_impl(true, |this| {
|
||||
this.invalid_visibility(&item.vis, None);
|
||||
if let TyKind::Err = self_ty.kind {
|
||||
|
@ -957,7 +957,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
});
|
||||
return; // Avoid visiting again.
|
||||
}
|
||||
ItemKind::Impl {
|
||||
ItemKind::Impl(box ImplKind {
|
||||
unsafety,
|
||||
polarity,
|
||||
defaultness,
|
||||
|
@ -966,7 +966,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
of_trait: None,
|
||||
ref self_ty,
|
||||
items: _,
|
||||
} => {
|
||||
}) => {
|
||||
let error = |annotation_span, annotation| {
|
||||
let mut err = self.err_handler().struct_span_err(
|
||||
self_ty.span,
|
||||
|
@ -998,7 +998,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
.emit();
|
||||
}
|
||||
}
|
||||
ItemKind::Fn(def, _, _, ref body) => {
|
||||
ItemKind::Fn(box FnKind(def, _, _, ref body)) => {
|
||||
self.check_defaultness(item.span, def);
|
||||
|
||||
if body.is_none() {
|
||||
|
@ -1027,7 +1027,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
ItemKind::Trait(is_auto, _, ref generics, ref bounds, ref trait_items) => {
|
||||
ItemKind::Trait(box TraitKind(
|
||||
is_auto,
|
||||
_,
|
||||
ref generics,
|
||||
ref bounds,
|
||||
ref trait_items,
|
||||
)) => {
|
||||
if is_auto == IsAuto::Yes {
|
||||
// Auto traits cannot have generics, super traits nor contain items.
|
||||
self.deny_generic_params(generics, item.ident.span);
|
||||
|
@ -1075,7 +1081,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
let msg = "free static item without body";
|
||||
self.error_item_without_body(item.span, "static", msg, " = <expr>;");
|
||||
}
|
||||
ItemKind::TyAlias(def, _, ref bounds, ref body) => {
|
||||
ItemKind::TyAlias(box TyAliasKind(def, _, ref bounds, ref body)) => {
|
||||
self.check_defaultness(item.span, def);
|
||||
if body.is_none() {
|
||||
let msg = "free type alias without body";
|
||||
|
@ -1091,12 +1097,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
|
||||
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
|
||||
match &fi.kind {
|
||||
ForeignItemKind::Fn(def, sig, _, body) => {
|
||||
ForeignItemKind::Fn(box FnKind(def, sig, _, body)) => {
|
||||
self.check_defaultness(fi.span, *def);
|
||||
self.check_foreign_fn_bodyless(fi.ident, body.as_deref());
|
||||
self.check_foreign_fn_headerless(fi.ident, fi.span, sig.header);
|
||||
}
|
||||
ForeignItemKind::TyAlias(def, generics, bounds, body) => {
|
||||
ForeignItemKind::TyAlias(box TyAliasKind(def, generics, bounds, body)) => {
|
||||
self.check_defaultness(fi.span, *def);
|
||||
self.check_foreign_kind_bodyless(fi.ident, "type", body.as_ref().map(|b| b.span));
|
||||
self.check_type_no_bounds(bounds, "`extern` blocks");
|
||||
|
@ -1336,10 +1342,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
AssocItemKind::Const(_, _, body) => {
|
||||
self.check_impl_item_provided(item.span, body, "constant", " = <expr>;");
|
||||
}
|
||||
AssocItemKind::Fn(_, _, _, body) => {
|
||||
AssocItemKind::Fn(box FnKind(_, _, _, body)) => {
|
||||
self.check_impl_item_provided(item.span, body, "function", " { <body> }");
|
||||
}
|
||||
AssocItemKind::TyAlias(_, _, bounds, body) => {
|
||||
AssocItemKind::TyAlias(box TyAliasKind(_, _, bounds, body)) => {
|
||||
self.check_impl_item_provided(item.span, body, "type", " = <type>;");
|
||||
self.check_type_no_bounds(bounds, "`impl`s");
|
||||
}
|
||||
|
@ -1349,7 +1355,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
|
||||
if ctxt == AssocCtxt::Trait || self.in_trait_impl {
|
||||
self.invalid_visibility(&item.vis, None);
|
||||
if let AssocItemKind::Fn(_, sig, _, _) = &item.kind {
|
||||
if let AssocItemKind::Fn(box FnKind(_, sig, _, _)) = &item.kind {
|
||||
self.check_trait_fn_not_const(sig.header.constness);
|
||||
self.check_trait_fn_not_async(item.span, sig.header.asyncness);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue