Skip to content

Impl Eq/PartialEq on FnKind, improve docs #27857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/ast_map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a> FnLikeNode<'a> {
visit::FkItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
};
let closure = |_: ClosureParts| {
visit::FkFnBlock
visit::FkClosure
};
let method = |_, ident, sig: &'a ast::MethodSig, vis, _, _| {
visit::FkMethod(ident, sig, vis)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
sp: Span,
fn_id: NodeId) {
match kind {
visit::FkFnBlock => {}
visit::FkClosure => {}
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
visit::walk_fn(self, fk, fd, b, s);
self.param_envs.pop();
}
visit::FkFnBlock(..) => {
visit::FkClosure(..) => {
visit::walk_fn(self, fk, fd, b, s);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
this.walk_fn(fk, fd, b, s)
})
}
visit::FkFnBlock(..) => {
visit::FkClosure(..) => {
self.walk_fn(fk, fd, b, s)
}
}
Expand Down Expand Up @@ -484,7 +484,7 @@ impl<'a> LifetimeContext<'a> {
self.visit_generics(&sig.generics);
self.visit_explicit_self(&sig.explicit_self);
}
visit::FkFnBlock(..) => {
visit::FkClosure(..) => {
visit::walk_fn_decl(self, fd);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
self.free_region_map = old_free_region_map;
}

visit::FkFnBlock => {
visit::FkClosure => {
borrowck_fn(self, fk, fd, b, s, id);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ impl LintPass for UnconditionalRecursion {
cx.tcx.impl_or_trait_item(local_def(id)).as_opt_method()
}
// 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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
self.visit_explicit_self(&sig.explicit_self);
MethodRibKind
}
visit::FkFnBlock(..) => ClosureRibKind(node_id)
visit::FkClosure(..) => ClosureRibKind(node_id)
};
self.resolve_function(rib_kind, declaration, block);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
b: &'v ast::Block, span: Span, id: ast::NodeId) {
match fk {
visit::FkFnBlock | visit::FkItemFn(..) => {}
visit::FkClosure | visit::FkItemFn(..) => {}
visit::FkMethod(..) => {
match self.tcx().impl_or_trait_item(local_def(id)) {
ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
visit::FkMethod(_, sig, _) => {
self.visit_generics_helper(&sig.generics)
}
visit::FkFnBlock => {}
visit::FkClosure => {}
}

for argument in &function_declaration.inputs {
Expand Down
11 changes: 5 additions & 6 deletions src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ use codemap::Span;
use ptr::P;
use owned_slice::OwnedSlice;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum FnKind<'a> {
/// fn foo() or extern "Abi" fn foo()
FkItemFn(Ident, &'a Generics, Unsafety, Constness, Abi, Visibility),

/// fn foo(&self)
FkMethod(Ident, &'a MethodSig, Option<Visibility>),

/// |x, y| ...
/// proc(x, y) ...
FkFnBlock,
/// |x, y| {}
FkClosure,
}

/// Each method of the Visitor trait is a hook to be potentially
Expand Down Expand Up @@ -616,7 +615,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
visitor.visit_generics(&sig.generics);
visitor.visit_explicit_self(&sig.explicit_self);
}
FkFnBlock(..) => {}
FkClosure(..) => {}
}

visitor.visit_block(function_body)
Expand Down Expand Up @@ -817,7 +816,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
}
}
ExprClosure(_, ref function_declaration, ref body) => {
visitor.visit_fn(FkFnBlock,
visitor.visit_fn(FkClosure,
&**function_declaration,
&**body,
expression.span,
Expand Down