Skip to content

Commit 797d0ba

Browse files
committed
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`.
2 parents db67cbe + c03bf18 commit 797d0ba

File tree

10 files changed

+15
-16
lines changed

10 files changed

+15
-16
lines changed

src/librustc/ast_map/blocks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<'a> FnLikeNode<'a> {
191191
visit::FkItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
192192
};
193193
let closure = |_: ClosureParts| {
194-
visit::FkFnBlock
194+
visit::FkClosure
195195
};
196196
let method = |_, ident, sig: &'a ast::MethodSig, vis, _, _| {
197197
visit::FkMethod(ident, sig, vis)

src/librustc/middle/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
10071007
sp: Span,
10081008
fn_id: NodeId) {
10091009
match kind {
1010-
visit::FkFnBlock => {}
1010+
visit::FkClosure => {}
10111011
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
10121012
}
10131013

src/librustc/middle/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
225225
visit::walk_fn(self, fk, fd, b, s);
226226
self.param_envs.pop();
227227
}
228-
visit::FkFnBlock(..) => {
228+
visit::FkClosure(..) => {
229229
visit::walk_fn(self, fk, fd, b, s);
230230
}
231231
}

src/librustc/middle/resolve_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
186186
this.walk_fn(fk, fd, b, s)
187187
})
188188
}
189-
visit::FkFnBlock(..) => {
189+
visit::FkClosure(..) => {
190190
self.walk_fn(fk, fd, b, s)
191191
}
192192
}
@@ -484,7 +484,7 @@ impl<'a> LifetimeContext<'a> {
484484
self.visit_generics(&sig.generics);
485485
self.visit_explicit_self(&sig.explicit_self);
486486
}
487-
visit::FkFnBlock(..) => {
487+
visit::FkClosure(..) => {
488488
visit::walk_fn_decl(self, fd);
489489
}
490490
}

src/librustc_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
6868
self.free_region_map = old_free_region_map;
6969
}
7070

71-
visit::FkFnBlock => {
71+
visit::FkClosure => {
7272
borrowck_fn(self, fk, fd, b, s, id);
7373
}
7474
}

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ impl LintPass for UnconditionalRecursion {
21372137
cx.tcx.impl_or_trait_item(DefId::local(id)).as_opt_method()
21382138
}
21392139
// closures can't recur, so they don't matter.
2140-
visit::FkFnBlock => return
2140+
visit::FkClosure => return
21412141
};
21422142

21432143
// Walk through this function (say `f`) looking to see if

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
542542
self.visit_explicit_self(&sig.explicit_self);
543543
MethodRibKind
544544
}
545-
visit::FkFnBlock(..) => ClosureRibKind(node_id)
545+
visit::FkClosure(..) => ClosureRibKind(node_id)
546546
};
547547
self.resolve_function(rib_kind, declaration, block);
548548
}

src/librustc_typeck/check/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
428428
fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
429429
b: &'v ast::Block, span: Span, id: ast::NodeId) {
430430
match fk {
431-
visit::FkFnBlock | visit::FkItemFn(..) => {}
431+
visit::FkClosure | visit::FkItemFn(..) => {}
432432
visit::FkMethod(..) => {
433433
match self.tcx().impl_or_trait_item(DefId::local(id)) {
434434
ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {

src/libsyntax/ast_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
438438
visit::FkMethod(_, sig, _) => {
439439
self.visit_generics_helper(&sig.generics)
440440
}
441-
visit::FkFnBlock => {}
441+
visit::FkClosure => {}
442442
}
443443

444444
for argument in &function_declaration.inputs {

src/libsyntax/visit.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ use codemap::Span;
3232
use ptr::P;
3333
use owned_slice::OwnedSlice;
3434

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

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

43-
/// |x, y| ...
44-
/// proc(x, y) ...
45-
FkFnBlock,
43+
/// |x, y| {}
44+
FkClosure,
4645
}
4746

4847
/// 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,
616615
visitor.visit_generics(&sig.generics);
617616
visitor.visit_explicit_self(&sig.explicit_self);
618617
}
619-
FkFnBlock(..) => {}
618+
FkClosure(..) => {}
620619
}
621620

622621
visitor.visit_block(function_body)
@@ -817,7 +816,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
817816
}
818817
}
819818
ExprClosure(_, ref function_declaration, ref body) => {
820-
visitor.visit_fn(FkFnBlock,
819+
visitor.visit_fn(FkClosure,
821820
&**function_declaration,
822821
&**body,
823822
expression.span,

0 commit comments

Comments
 (0)