Skip to content

Commit 4fde10f

Browse files
committed
librustc: Remove fn@, fn~, and fn& from librustc. rs=defun
1 parent 94ee816 commit 4fde10f

File tree

20 files changed

+58
-52
lines changed

20 files changed

+58
-52
lines changed

src/libcore/core.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,8 @@ pub mod core {
253253

254254
pub use cmp;
255255
pub use condition;
256-
pub use kinds;
257-
pub use ops;
258256
pub use option;
257+
pub use kinds;
259258
pub use sys;
260259
pub use pipes;
261260
}

src/librustc/front/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use syntax::{ast, fold, attr};
1515
use core::option;
1616
use core::vec;
1717

18-
type in_cfg_pred = fn@(+attrs: ~[ast::attribute]) -> bool;
18+
type in_cfg_pred = @fn(+attrs: ~[ast::attribute]) -> bool;
1919

2020
struct Context {
2121
in_cfg: in_cfg_pred

src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax::fold;
2929
use syntax::print::pprust;
3030
use syntax::{ast, ast_util};
3131

32-
type node_id_gen = fn@() -> ast::node_id;
32+
type node_id_gen = @fn() -> ast::node_id;
3333

3434
struct Test {
3535
span: span,

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use writer = std::ebml::writer;
5757
// used by astencode:
5858
type abbrev_map = oldmap::HashMap<ty::t, tyencode::ty_abbrev>;
5959

60-
pub type encode_inlined_item = fn@(ecx: @EncodeContext,
60+
pub type encode_inlined_item = @fn(ecx: @EncodeContext,
6161
ebml_w: writer::Encoder,
6262
path: &[ast_map::path_elt],
6363
ii: ast::inlined_item);

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn parse_ident(st: @mut PState, last: char) -> ast::ident {
8181
return parse_ident_(st, |a| is_last(last, a) );
8282
}
8383

84-
fn parse_ident_(st: @mut PState, is_last: fn@(char) -> bool) ->
84+
fn parse_ident_(st: @mut PState, is_last: @fn(char) -> bool) ->
8585
ast::ident {
8686
let mut rslt = ~"";
8787
while !is_last(peek(st)) {

src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ use middle::ty::Vid;
2929
pub struct ctxt {
3030
diag: span_handler,
3131
// Def -> str Callback:
32-
ds: fn@(def_id) -> ~str,
32+
ds: @fn(def_id) -> ~str,
3333
// The type context.
3434
tcx: ty::ctxt,
35-
reachable: fn@(node_id) -> bool,
35+
reachable: @fn(node_id) -> bool,
3636
abbrevs: abbrev_ctxt
3737
}
3838

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ fn encode_side_tables_for_ii(ecx: @e::EncodeContext,
843843
let ebml_w = copy ebml_w;
844844
ast_util::visit_ids_for_inlined_item(
845845
ii,
846-
fn@(id: ast::node_id) {
846+
|id: ast::node_id| {
847847
// Note: this will cause a copy of ebml_w, which is bad as
848848
// it has mut fields. But I believe it's harmless since
849849
// we generate balanced EBML.

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn req_loans_in_expr(ex: @ast::expr,
251251
// Receivers in method calls are always passed by ref.
252252
//
253253
// Here, the field a.b is in fact a closure. Eventually, this
254-
// should be an fn&, but for now it's an fn@. In any case,
254+
// should be an &fn, but for now it's an @fn. In any case,
255255
// the enclosing scope is either the call where it is a rcvr
256256
// (if used like `a.b(...)`), the call where it's an argument
257257
// (if used like `x(a.b)`), or the block (if used like `let x

src/librustc/middle/freevars.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
4646

4747
fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
4848

49-
let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) {
49+
let walk_expr: @fn(expr: @ast::expr, &&depth: int, v: visit::vt<int>) =
50+
|expr, depth, v| {
5051
match expr.node {
5152
ast::expr_fn(_, _, _, _) => {
5253
visit::visit_expr(expr, depth + 1, v);
@@ -100,8 +101,11 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) ->
100101
freevar_map {
101102
let freevars = HashMap();
102103
103-
let walk_fn = fn@(_fk: &visit::fn_kind, _decl: &ast::fn_decl,
104-
blk: &ast::blk, _sp: span, nid: ast::node_id) {
104+
let walk_fn: @fn(&visit::fn_kind,
105+
&ast::fn_decl,
106+
&ast::blk,
107+
span,
108+
ast::node_id) = |_, _, blk, _, nid| {
105109
let vars = collect_freevars(def_map, blk);
106110
freevars.insert(nid, vars);
107111
};

src/librustc/middle/kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn check_crate(tcx: ty::ctxt,
8484
visit_expr: check_expr,
8585
visit_fn: check_fn,
8686
visit_ty: check_ty,
87-
visit_item: fn@(i: @item, cx: Context, v: visit::vt<Context>) {
87+
visit_item: |i, cx, v| {
8888
visit::visit_item(i, Context { current_item: i.id,.. cx }, v);
8989
},
9090
.. *visit::default_visitor()
@@ -93,7 +93,7 @@ pub fn check_crate(tcx: ty::ctxt,
9393
tcx.sess.abort_if_errors();
9494
}
9595

96-
type check_fn = fn@(Context, @freevar_entry);
96+
type check_fn = @fn(Context, @freevar_entry);
9797

9898
// Yields the appropriate function to check the kind of closed over
9999
// variables. `id` is the node_id for some expression that creates the

src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
10031003
})
10041004
}
10051005
1006-
pub type mk_fail = fn@() -> BasicBlockRef;
1006+
pub type mk_fail = @fn() -> BasicBlockRef;
10071007
10081008
pub fn pick_col(m: &[@Match]) -> uint {
10091009
fn score(p: @ast::pat) -> uint {

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ pub fn compare_scalar_values(cx: block,
634634
}
635635
}
636636

637-
pub type val_pair_fn = fn@(block, ValueRef, ValueRef) -> block;
638-
pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> block;
637+
pub type val_pair_fn = @fn(block, ValueRef, ValueRef) -> block;
638+
pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> block;
639639

640640
pub fn load_inbounds(cx: block, p: ValueRef, idxs: &[uint]) -> ValueRef {
641641
return Load(cx, GEPi(cx, p, idxs));

src/librustc/middle/trans/closure.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use syntax::print::pprust::expr_to_str;
4242
// roughly as follows:
4343
//
4444
// struct rust_opaque_box { // see rust_internal.h
45-
// unsigned ref_count; // only used for fn@()
45+
// unsigned ref_count; // only used for @fn()
4646
// type_desc *tydesc; // describes closure_data struct
4747
// rust_opaque_box *prev; // (used internally by memory alloc)
4848
// rust_opaque_box *next; // (used internally by memory alloc)
@@ -57,7 +57,7 @@ use syntax::print::pprust::expr_to_str;
5757
// };
5858
//
5959
// Note that the closure is itself a rust_opaque_box. This is true
60-
// even for fn~ and fn&, because we wish to keep binary compatibility
60+
// even for ~fn and &fn, because we wish to keep binary compatibility
6161
// between all kinds of closures. The allocation strategy for this
6262
// closure depends on the closure type. For a sendfn, the closure
6363
// (and the referenced type descriptors) will be allocated in the
@@ -440,11 +440,10 @@ pub fn trans_expr_fn(bcx: block,
440440
}
441441

442442
pub fn make_closure_glue(
443-
cx: block,
444-
v: ValueRef,
445-
t: ty::t,
446-
glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block) -> block
447-
{
443+
cx: block,
444+
v: ValueRef,
445+
t: ty::t,
446+
glue_fn: @fn(block, v: ValueRef, t: ty::t) -> block) -> block {
448447
let _icx = cx.insn_ctxt("closure::make_closure_glue");
449448
let bcx = cx;
450449
let tcx = cx.tcx();
@@ -483,7 +482,7 @@ pub fn make_opaque_cbox_take_glue(
483482
}
484483
}
485484

486-
// fn~ requires a deep copy.
485+
// ~fn requires a deep copy.
487486
let ccx = bcx.ccx(), tcx = ccx.tcx;
488487
let llopaquecboxty = T_opaque_box_ptr(ccx);
489488
let cbox_in = Load(bcx, cboxptr);

src/librustc/middle/trans/common.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ use syntax::parse::token::ident_interner;
6161
use syntax::print::pprust::expr_to_str;
6262
use syntax::{ast, ast_map};
6363

64-
pub type namegen = fn@(~str) -> ident;
64+
pub type namegen = @fn(~str) -> ident;
6565
pub fn new_namegen(intr: @ident_interner) -> namegen {
66-
return fn@(prefix: ~str) -> ident {
66+
let f: @fn(~str) -> ident = |prefix| {
6767
// XXX: Bad copies.
68-
return intr.gensym(@fmt!("%s_%u",
69-
prefix,
70-
intr.gensym(@copy prefix).repr))
68+
intr.gensym(@fmt!("%s_%u",
69+
prefix,
70+
intr.gensym(@copy prefix).repr))
7171
};
72+
f
7273
}
7374

7475
pub type addrspace = c_uint;
@@ -81,10 +82,11 @@ pub type addrspace = c_uint;
8182
pub const default_addrspace: addrspace = 0;
8283
pub const gc_box_addrspace: addrspace = 1;
8384

84-
pub type addrspace_gen = fn@() -> addrspace;
85+
pub type addrspace_gen = @fn() -> addrspace;
8586
pub fn new_addrspace_gen() -> addrspace_gen {
8687
let i = @mut 1;
87-
return fn@() -> addrspace { *i += 1; *i };
88+
let result: addrspace_gen = || { *i += 1; *i };
89+
result
8890
}
8991

9092
pub struct tydesc_info {
@@ -349,8 +351,8 @@ pub enum cleantype {
349351
}
350352
351353
pub enum cleanup {
352-
clean(fn@(block) -> block, cleantype),
353-
clean_temp(ValueRef, fn@(block) -> block, cleantype),
354+
clean(@fn(block) -> block, cleantype),
355+
clean_temp(ValueRef, @fn(block) -> block, cleantype),
354356
}
355357
356358
// Used to remember and reuse existing cleanup paths
@@ -1034,7 +1036,7 @@ pub fn T_typaram_ptr(tn: @TypeNames) -> TypeRef {
10341036
}
10351037

10361038
pub fn T_opaque_cbox_ptr(cx: @CrateContext) -> TypeRef {
1037-
// closures look like boxes (even when they are fn~ or fn&)
1039+
// closures look like boxes (even when they are ~fn or &fn)
10381040
// see trans_closure.rs
10391041
return T_opaque_box_ptr(cx);
10401042
}

src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
709709
return inf;
710710
}
711711
712-
pub type glue_helper = fn@(block, ValueRef, ty::t);
712+
pub type glue_helper = @fn(block, ValueRef, ty::t);
713713
714714
pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
715715
+name: ~str) -> ValueRef {

src/librustc/middle/trans/tvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ pub fn get_base_and_len(bcx: block,
521521
}
522522
}
523523

524-
pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> Result;
524+
pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> Result;
525525

526-
pub type iter_vec_block = fn(block, ValueRef, ty::t) -> block;
526+
pub type iter_vec_block = &fn(block, ValueRef, ty::t) -> block;
527527

528528
pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
529529
fill: ValueRef, f: iter_vec_block) -> block {

src/librustc/middle/ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ pub enum sty {
525525
// "Fake" types, used for trans purposes
526526
ty_type, // type_desc*
527527
ty_opaque_box, // used by monomorphizer to represent any @ box
528-
ty_opaque_closure_ptr(Sigil), // ptr to env for fn, fn@, fn~
528+
ty_opaque_closure_ptr(Sigil), // ptr to env for &fn, @fn, ~fn
529529
ty_unboxed_vec(mt),
530530
}
531531

@@ -1102,8 +1102,8 @@ pub pure fn mach_sty(cfg: @session::config, t: t) -> sty {
11021102
}
11031103

11041104
pub fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode {
1105-
// FIXME(#2202) --- We retain by-ref for fn& things to workaround a
1106-
// memory leak that otherwise results when @fn is upcast to &fn.
1105+
// FIXME(#2202) --- We retain by-ref for &fn things to workaround a
1106+
// memory leak that otherwise results when @fn is upcast to &fn.
11071107
match ty::get(ty).sty {
11081108
ty::ty_closure(ClosureTy {sigil: ast::BorrowedSigil, _}) => {
11091109
return ast::by_ref;

src/librustc/middle/typeck/check/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
389389
self_info: Option<SelfInfo>) {
390390
let tcx = fcx.ccx.tcx;
391391

392-
let assign = fn@(nid: ast::node_id, ty_opt: Option<ty::t>) {
392+
let assign: @fn(ast::node_id, Option<ty::t>) = |nid, ty_opt| {
393393
match ty_opt {
394394
None => {
395395
// infer the variable's type
@@ -432,8 +432,8 @@ pub fn check_fn(ccx: @mut CrateCtxt,
432432
}
433433

434434
// Add explicitly-declared locals.
435-
let visit_local = fn@(local: @ast::local,
436-
&&e: (), v: visit::vt<()>) {
435+
let visit_local: @fn(@ast::local, &&e: (), visit::vt<()>) =
436+
|local, e, v| {
437437
let o_ty = match local.node.ty.node {
438438
ast::ty_infer => None,
439439
_ => Some(fcx.to_ty(local.node.ty))
@@ -447,7 +447,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
447447
};
448448

449449
// Add pattern bindings.
450-
let visit_pat = fn@(p: @ast::pat, &&e: (), v: visit::vt<()>) {
450+
let visit_pat: @fn(@ast::pat, &&e: (), visit::vt<()>) = |p, e, v| {
451451
match p.node {
452452
ast::pat_ident(_, path, _)
453453
if pat_util::pat_is_binding(fcx.ccx.tcx.def_map, p) => {
@@ -462,7 +462,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
462462
visit::visit_pat(p, e, v);
463463
};
464464

465-
let visit_block = fn@(b: &ast::blk, &&e: (), v: visit::vt<()>) {
465+
let visit_block: @fn(&ast::blk, &&e: (), visit::vt<()>) = |b, e, v| {
466466
// non-obvious: the `blk` variable maps to region lb, so
467467
// we have to keep this up-to-date. This
468468
// is... unfortunate. It'd be nice to not need this.

src/librustc/rustc.rc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ diagnostic emitter which records when we hit a fatal error. If the task
315315
fails without recording a fatal error then we've encountered a compiler
316316
bug and need to present an error.
317317
*/
318-
pub fn monitor(+f: fn~(diagnostic::Emitter)) {
318+
pub fn monitor(+f: ~fn(diagnostic::Emitter)) {
319319
use core::cell::Cell;
320320
use core::comm::*;
321321
let (p, ch) = stream();
@@ -326,8 +326,10 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) {
326326
let ch_capture = ch.clone();
327327
// The 'diagnostics emitter'. Every error, warning, etc. should
328328
// go through this function.
329-
let demitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>,
330-
msg: &str, lvl: diagnostic::level) {
329+
let demitter: @fn(Option<(@codemap::CodeMap, codemap::span)>,
330+
&str,
331+
diagnostic::level) =
332+
|cmsp, msg, lvl| {
331333
if lvl == diagnostic::fatal {
332334
ch_capture.send(fatal);
333335
}

src/librustc/util/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
5959

6060
// Takes a predicate p, returns true iff p is true for any subexpressions
6161
// of b -- skipping any inner loops (loop, while, loop_body)
62-
pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
62+
pub fn loop_query(b: &ast::blk, p: @fn(ast::expr_) -> bool) -> bool {
6363
let rs = @mut false;
6464
let visit_expr: @fn(@ast::expr,
6565
&&flag: @mut bool,
@@ -82,7 +82,7 @@ pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
8282

8383
// Takes a predicate p, returns true iff p is true for any subexpressions
8484
// of b -- skipping any inner loops (loop, while, loop_body)
85-
pub fn block_query(b: &ast::blk, p: fn@(@ast::expr) -> bool) -> bool {
85+
pub fn block_query(b: &ast::blk, p: @fn(@ast::expr) -> bool) -> bool {
8686
let rs = @mut false;
8787
let visit_expr: @fn(@ast::expr,
8888
&&flag: @mut bool,

0 commit comments

Comments
 (0)