syntax: move MethMac to MacImplItem and combine {Provided,Required}Method into MethodTraitItem.

This commit is contained in:
Eduard Burtescu
2015-03-11 23:38:58 +02:00
parent ce10fa8d12
commit 9da918548d
37 changed files with 466 additions and 551 deletions

View File

@@ -82,7 +82,7 @@ use syntax::ast::{TyRptr, TyStr, TyUs, TyU8, TyU16, TyU32, TyU64, TyUint};
use syntax::ast::{TypeImplItem};
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::{PostExpansionMethod, local_def, walk_pat};
use syntax::ast_util::{local_def, walk_pat};
use syntax::attr::AttrMetaMethods;
use syntax::ext::mtwt;
use syntax::parse::token::{self, special_names, special_idents};
@@ -242,9 +242,9 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
self.visit_generics(generics);
ItemRibKind
}
visit::FkMethod(_, method) => {
self.visit_generics(&method.pe_sig().generics);
self.visit_explicit_self(&method.pe_sig().explicit_self);
visit::FkMethod(_, sig) => {
self.visit_generics(&sig.generics);
self.visit_explicit_self(&sig.explicit_self);
MethodRibKind
}
visit::FkFnBlock(..) => ClosureRibKind(node_id)
@@ -2814,16 +2814,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// FIXME #4951: Do we need a node ID here?
let type_parameters = match trait_item.node {
ast::RequiredMethod(ref sig) => {
ast::MethodTraitItem(ref sig, _) => {
HasTypeParameters(&sig.generics,
FnSpace,
MethodRibKind)
}
ast::ProvidedMethod(ref m) => {
HasTypeParameters(&m.pe_sig().generics,
FnSpace,
MethodRibKind)
}
ast::TypeTraitItem(..) => {
this.check_if_primitive_type_name(trait_item.ident.name,
trait_item.span);
@@ -3066,7 +3061,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
this.with_current_self_type(self_type, |this| {
for impl_item in impl_items {
match impl_item.node {
MethodImplItem(ref method) => {
MethodImplItem(ref sig, _) => {
// If this is a trait impl, ensure the method
// exists in trait
this.check_trait_item(impl_item.ident.name,
@@ -3075,7 +3070,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// We also need a new scope for the method-
// specific type parameters.
let type_parameters =
HasTypeParameters(&method.pe_sig().generics,
HasTypeParameters(&sig.generics,
FnSpace,
MethodRibKind);
this.with_type_parameter_rib(type_parameters, |this| {
@@ -3090,6 +3085,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
this.visit_ty(ty);
}
ast::MacImplItem(_) => {}
}
}
});
@@ -3953,19 +3949,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
fn is_static_method(this: &Resolver, did: DefId) -> bool {
if did.krate == ast::LOCAL_CRATE {
let explicit_self = match this.ast_map.get(did.node) {
let sig = match this.ast_map.get(did.node) {
ast_map::NodeTraitItem(trait_item) => match trait_item.node {
ast::RequiredMethod(ref m) => &m.explicit_self,
ast::ProvidedMethod(ref m) => &m.pe_sig().explicit_self,
ast::MethodTraitItem(ref sig, _) => sig,
_ => return false
},
ast_map::NodeImplItem(impl_item) => match impl_item.node {
ast::MethodImplItem(ref m) => &m.pe_sig().explicit_self,
ast::MethodImplItem(ref sig, _) => sig,
_ => return false
},
_ => return false
};
explicit_self.node == ast::SelfStatic
sig.explicit_self.node == ast::SelfStatic
} else {
csearch::is_static_method(&this.session.cstore, did)
}