diff options
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/codemap.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 15 | ||||
| -rw-r--r-- | src/comp/syntax/print/pprust.rs | 12 | ||||
| -rw-r--r-- | src/comp/syntax/visit.rs | 30 |
5 files changed, 36 insertions, 25 deletions
diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 7d7df57863c..418be6116ce 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -32,7 +32,7 @@ fn next_line(file: filemap, chpos: uint, byte_pos: uint) { file.lines += [{ch: chpos, byte: byte_pos}]; } -type lookup_fn = fn(file_pos) -> uint; +type lookup_fn = fn@(file_pos) -> uint; fn lookup_pos(map: codemap, pos: uint, lookup: lookup_fn) -> loc { let len = vec::len(map.files); diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 8f6f1a5828a..719c354b8a6 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -532,7 +532,7 @@ fn block_to_ident(blk: blk_) -> option::t<ident> { fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { fn select_pt_1(cx: ext_ctxt, m: matchable, - fn_m: fn(ast::mac) -> match_result) -> match_result { + fn_m: block(ast::mac) -> match_result) -> match_result { ret alt m { match_expr(e) { alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 57f21e6113b..3a7f85b56c4 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -480,14 +480,21 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty { expect(p, token::RBRACKET); } else if eat_word(p, "fn") { let proto = parse_fn_ty_proto(p); + alt proto { + ast::proto_bare. { p.warn("fn is deprecated, use native fn"); } + _ { /* fallthrough */ } + } t = parse_ty_fn(proto, p); } else if eat_word(p, "block") { t = parse_ty_fn(ast::proto_block, p); + } else if eat_word(p, "native") { + expect_word(p, "fn"); + t = parse_ty_fn(ast::proto_bare, p); } else if eat_word(p, "lambda") { - //(breaks prettyprinting!) p.warn("lambda is deprecated, use fn@"); + p.warn("lambda is deprecated, use fn@"); t = parse_ty_fn(ast::proto_box, p); } else if eat_word(p, "sendfn") { - //(breaks prettyprinting!) p.warn("sendfn is deprecated, use fn~"); + p.warn("sendfn is deprecated, use fn~"); t = parse_ty_fn(ast::proto_uniq, p); } else if p.token == token::MOD_SEP || is_ident(p.token) { let path = parse_path(p); @@ -786,6 +793,10 @@ fn parse_bottom_expr(p: parser) -> pexpr { ret pexpr(parse_alt_expr(p)); } else if eat_word(p, "fn") { let proto = parse_fn_ty_proto(p); + alt proto { + ast::proto_bare. { p.warn("fn expr are deprecated, use fn@"); } + _ { /* fallthrough */ } + } ret pexpr(parse_fn_expr(p, proto)); } else if eat_word(p, "block") { ret pexpr(parse_fn_expr(p, ast::proto_block)); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 6de712e14be..6c5fd6b0354 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -194,7 +194,7 @@ fn synth_comment(s: ps, text: str) { word(s.s, "*/"); } -fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN)) { +fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: block(ps, IN)) { box(s, 0u, b); let first = true; for elt: IN in elts { @@ -205,8 +205,8 @@ fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN)) { } -fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN), - get_span: fn(IN) -> codemap::span) { +fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN], op: block(ps, IN), + get_span: block(IN) -> codemap::span) { box(s, 0u, b); let len = vec::len::<IN>(elts); let i = 0u; @@ -1246,7 +1246,7 @@ fn print_view_item(s: ps, item: @ast::view_item) { for elt: ast::ident in *mod_path { word(s.s, elt); word(s.s, "::"); } word(s.s, "{"); commasep(s, inconsistent, idents, - fn (s: ps, w: ast::import_ident) { word(s.s, w.node.name) }); + fn@(s: ps, w: ast::import_ident) { word(s.s, w.node.name) }); word(s.s, "}"); } ast::view_item_import_glob(ids, _) { @@ -1261,7 +1261,7 @@ fn print_view_item(s: ps, item: @ast::view_item) { ast::view_item_export(ids, _) { head(s, "export"); commasep(s, inconsistent, ids, - fn (s: ps, &&w: ast::ident) { word(s.s, w) }); + fn@(s: ps, &&w: ast::ident) { word(s.s, w) }); } } word(s.s, ";"); @@ -1604,7 +1604,7 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str { fn proto_to_str(p: ast::proto) -> str { ret alt p { - ast::proto_bare. { "fn" } + ast::proto_bare. { "native fn" } ast::proto_block. { "block" } ast::proto_uniq. { "fn~" } ast::proto_box. { "fn@" } diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index 33233e9158f..d4cd956d2f1 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -391,22 +391,22 @@ type simple_visitor = fn simple_ignore_ty(_t: @ty) {} fn default_simple_visitor() -> simple_visitor { - ret @{visit_mod: fn(_m: _mod, _sp: span) { }, - visit_view_item: fn(_vi: @view_item) { }, - visit_native_item: fn(_ni: @native_item) { }, - visit_item: fn(_i: @item) { }, - visit_local: fn(_l: @local) { }, - visit_block: fn(_b: ast::blk) { }, - visit_stmt: fn(_s: @stmt) { }, - visit_arm: fn(_a: arm) { }, - visit_pat: fn(_p: @pat) { }, - visit_decl: fn(_d: @decl) { }, - visit_expr: fn(_e: @expr) { }, + ret @{visit_mod: fn@(_m: _mod, _sp: span) { }, + visit_view_item: fn@(_vi: @view_item) { }, + visit_native_item: fn@(_ni: @native_item) { }, + visit_item: fn@(_i: @item) { }, + visit_local: fn@(_l: @local) { }, + visit_block: fn@(_b: ast::blk) { }, + visit_stmt: fn@(_s: @stmt) { }, + visit_arm: fn@(_a: arm) { }, + visit_pat: fn@(_p: @pat) { }, + visit_decl: fn@(_d: @decl) { }, + visit_expr: fn@(_e: @expr) { }, visit_ty: simple_ignore_ty, - visit_ty_params: fn(_ps: [ty_param]) {}, - visit_constr: fn(_p: @path, _sp: span, _id: node_id) { }, - visit_fn: fn(_fk: fn_kind, _d: fn_decl, _b: blk, _sp: span, - _id: node_id) { } + visit_ty_params: fn@(_ps: [ty_param]) {}, + visit_constr: fn@(_p: @path, _sp: span, _id: node_id) { }, + visit_fn: fn@(_fk: fn_kind, _d: fn_decl, _b: blk, _sp: span, + _id: node_id) { } }; } |
