Auto merge of #27857 - Manishearth:improve-fnkind, r=pnkfelix

Since enums are namespaced now, should we also remove the `Fk` prefixes from `FnKind` and remove the reexport? (The reexport must be removed because otherwise it clashes with glob imports containing `ItemFn`). IMO writing `FnKind::Method` is much clearer than `FkMethod`.
This commit is contained in:
bors 2015-08-24 12:47:57 +00:00
commit 797d0ba59c
10 changed files with 15 additions and 16 deletions

View File

@ -191,7 +191,7 @@ impl<'a> FnLikeNode<'a> {
visit::FkItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis) visit::FkItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
}; };
let closure = |_: ClosureParts| { let closure = |_: ClosureParts| {
visit::FkFnBlock visit::FkClosure
}; };
let method = |_, ident, sig: &'a ast::MethodSig, vis, _, _| { let method = |_, ident, sig: &'a ast::MethodSig, vis, _, _| {
visit::FkMethod(ident, sig, vis) visit::FkMethod(ident, sig, vis)

View File

@ -1007,7 +1007,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
sp: Span, sp: Span,
fn_id: NodeId) { fn_id: NodeId) {
match kind { match kind {
visit::FkFnBlock => {} visit::FkClosure => {}
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id), _ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
} }

View File

@ -225,7 +225,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
visit::walk_fn(self, fk, fd, b, s); visit::walk_fn(self, fk, fd, b, s);
self.param_envs.pop(); self.param_envs.pop();
} }
visit::FkFnBlock(..) => { visit::FkClosure(..) => {
visit::walk_fn(self, fk, fd, b, s); visit::walk_fn(self, fk, fd, b, s);
} }
} }

View File

@ -186,7 +186,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
this.walk_fn(fk, fd, b, s) this.walk_fn(fk, fd, b, s)
}) })
} }
visit::FkFnBlock(..) => { visit::FkClosure(..) => {
self.walk_fn(fk, fd, b, s) self.walk_fn(fk, fd, b, s)
} }
} }
@ -484,7 +484,7 @@ impl<'a> LifetimeContext<'a> {
self.visit_generics(&sig.generics); self.visit_generics(&sig.generics);
self.visit_explicit_self(&sig.explicit_self); self.visit_explicit_self(&sig.explicit_self);
} }
visit::FkFnBlock(..) => { visit::FkClosure(..) => {
visit::walk_fn_decl(self, fd); visit::walk_fn_decl(self, fd);
} }
} }

View File

@ -68,7 +68,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
self.free_region_map = old_free_region_map; self.free_region_map = old_free_region_map;
} }
visit::FkFnBlock => { visit::FkClosure => {
borrowck_fn(self, fk, fd, b, s, id); borrowck_fn(self, fk, fd, b, s, id);
} }
} }

View File

@ -2137,7 +2137,7 @@ impl LintPass for UnconditionalRecursion {
cx.tcx.impl_or_trait_item(DefId::local(id)).as_opt_method() cx.tcx.impl_or_trait_item(DefId::local(id)).as_opt_method()
} }
// closures can't recur, so they don't matter. // closures can't recur, so they don't matter.
visit::FkFnBlock => return visit::FkClosure => return
}; };
// Walk through this function (say `f`) looking to see if // Walk through this function (say `f`) looking to see if

View File

@ -542,7 +542,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
self.visit_explicit_self(&sig.explicit_self); self.visit_explicit_self(&sig.explicit_self);
MethodRibKind MethodRibKind
} }
visit::FkFnBlock(..) => ClosureRibKind(node_id) visit::FkClosure(..) => ClosureRibKind(node_id)
}; };
self.resolve_function(rib_kind, declaration, block); self.resolve_function(rib_kind, declaration, block);
} }

View File

@ -428,7 +428,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
fk: visit::FnKind<'v>, fd: &'v ast::FnDecl, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
b: &'v ast::Block, span: Span, id: ast::NodeId) { b: &'v ast::Block, span: Span, id: ast::NodeId) {
match fk { match fk {
visit::FkFnBlock | visit::FkItemFn(..) => {} visit::FkClosure | visit::FkItemFn(..) => {}
visit::FkMethod(..) => { visit::FkMethod(..) => {
match self.tcx().impl_or_trait_item(DefId::local(id)) { match self.tcx().impl_or_trait_item(DefId::local(id)) {
ty::ImplOrTraitItem::MethodTraitItem(ty_method) => { ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {

View File

@ -438,7 +438,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
visit::FkMethod(_, sig, _) => { visit::FkMethod(_, sig, _) => {
self.visit_generics_helper(&sig.generics) self.visit_generics_helper(&sig.generics)
} }
visit::FkFnBlock => {} visit::FkClosure => {}
} }
for argument in &function_declaration.inputs { for argument in &function_declaration.inputs {

View File

@ -32,7 +32,7 @@ use codemap::Span;
use ptr::P; use ptr::P;
use owned_slice::OwnedSlice; use owned_slice::OwnedSlice;
#[derive(Copy, Clone)] #[derive(Copy, Clone, PartialEq, Eq)]
pub enum FnKind<'a> { pub enum FnKind<'a> {
/// fn foo() or extern "Abi" fn foo() /// fn foo() or extern "Abi" fn foo()
FkItemFn(Ident, &'a Generics, Unsafety, Constness, Abi, Visibility), FkItemFn(Ident, &'a Generics, Unsafety, Constness, Abi, Visibility),
@ -40,9 +40,8 @@ pub enum FnKind<'a> {
/// fn foo(&self) /// fn foo(&self)
FkMethod(Ident, &'a MethodSig, Option<Visibility>), FkMethod(Ident, &'a MethodSig, Option<Visibility>),
/// |x, y| ... /// |x, y| {}
/// proc(x, y) ... FkClosure,
FkFnBlock,
} }
/// Each method of the Visitor trait is a hook to be potentially /// Each method of the Visitor trait is a hook to be potentially
@ -616,7 +615,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
visitor.visit_generics(&sig.generics); visitor.visit_generics(&sig.generics);
visitor.visit_explicit_self(&sig.explicit_self); visitor.visit_explicit_self(&sig.explicit_self);
} }
FkFnBlock(..) => {} FkClosure(..) => {}
} }
visitor.visit_block(function_body) visitor.visit_block(function_body)
@ -817,7 +816,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
} }
} }
ExprClosure(_, ref function_declaration, ref body) => { ExprClosure(_, ref function_declaration, ref body) => {
visitor.visit_fn(FkFnBlock, visitor.visit_fn(FkClosure,
&**function_declaration, &**function_declaration,
&**body, &**body,
expression.span, expression.span,