Skip to content

Commit ccec510

Browse files
committed
librustc: Stop parsing fn@, fn~, and fn&
1 parent ce3b17b commit ccec510

21 files changed

+22
-113
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ pub impl CheckLoanCtxt {
212212
(*self.fn_args).contains(&(did.node));
213213
if is_fn_arg { return; } // case (a) above
214214
}
215-
ast::expr_fn_block(*) | ast::expr_fn(*) |
216-
ast::expr_loop_body(*) | ast::expr_do_body(*) => {
215+
ast::expr_fn_block(*) | ast::expr_loop_body(*) |
216+
ast::expr_do_body(*) => {
217217
if self.is_stack_closure(expr.id) {
218218
// case (b) above
219219
return;
@@ -244,7 +244,7 @@ pub impl CheckLoanCtxt {
244244
}
245245

246246
// True if the expression with the given `id` is a stack closure.
247-
// The expression must be an expr_fn(*) or expr_fn_block(*)
247+
// The expression must be an expr_fn_block(*)
248248
fn is_stack_closure(@mut self, id: ast::node_id) -> bool {
249249
let fn_ty = ty::node_id_to_type(self.tcx(), id);
250250
match ty::get(fn_ty).sty {
@@ -262,10 +262,8 @@ pub impl CheckLoanCtxt {
262262
did.crate == ast::local_crate &&
263263
(*self.fn_args).contains(&(did.node))
264264
}
265-
ast::expr_fn_block(*) | ast::expr_fn(*) => {
266-
self.is_stack_closure(expr.id)
267-
}
268-
_ => false
265+
ast::expr_fn_block(*) => self.is_stack_closure(expr.id),
266+
_ => false,
269267
};
270268
}
271269

src/librustc/middle/check_loop.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
3838
expr_loop(ref b, _) => {
3939
(v.visit_block)(b, Context { in_loop: true,.. cx }, v);
4040
}
41-
expr_fn(*) => {
42-
visit::visit_expr(e, Context {
43-
in_loop: false,
44-
can_ret: true
45-
}, v);
46-
}
4741
expr_fn_block(_, ref b) => {
4842
(v.visit_block)(b, Context {
4943
in_loop: false,

src/librustc/middle/freevars.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
4949
let walk_expr: @fn(expr: @ast::expr, &&depth: int, v: visit::vt<int>) =
5050
|expr, depth, v| {
5151
match expr.node {
52-
ast::expr_fn(_, _, _, _) => {
53-
visit::visit_expr(expr, depth + 1, v);
54-
}
55-
ast::expr_fn_block(*) => {
56-
visit::visit_expr(expr, depth + 1, v);
57-
}
52+
ast::expr_fn_block(*) => visit::visit_expr(expr, depth + 1, v),
5853
ast::expr_path(*) => {
5954
let mut i = 0;
6055
match def_map.find(&expr.id) {

src/librustc/middle/liveness.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ fn visit_expr(expr: @expr, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
570570
}
571571
visit::visit_expr(expr, self, vt);
572572
}
573-
expr_fn(*) |
574573
expr_fn_block(*) => {
575574
// Interesting control flow (for loops can contain labeled
576575
// breaks or continues)
@@ -1123,8 +1122,8 @@ pub impl Liveness {
11231122
self.propagate_through_expr(e, succ)
11241123
}
11251124

1126-
expr_fn(_, _, ref blk, _) | expr_fn_block(_, ref blk) => {
1127-
debug!("%s is an expr_fn or expr_fn_block",
1125+
expr_fn_block(_, ref blk) => {
1126+
debug!("%s is an expr_fn_block",
11281127
expr_to_str(expr, self.tcx.sess.intr()));
11291128

11301129
/*
@@ -1592,7 +1591,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
15921591
visit::visit_expr(expr, self, vt);
15931592
}
15941593

1595-
expr_fn(*) | expr_fn_block(*) => {
1594+
expr_fn_block(*) => {
15961595
let caps = self.ir.captures(expr);
15971596
for caps.each |cap| {
15981597
let var = self.variable(cap.var_nid, expr.span);
@@ -1794,7 +1793,7 @@ pub impl @Liveness {
17941793
}
17951794

17961795
match move_expr.node {
1797-
expr_fn(*) | expr_fn_block(*) => {
1796+
expr_fn_block(*) => {
17981797
self.report_illegal_read(
17991798
move_expr.span, lnk, var, MovedValue);
18001799
let name = self.ir.variable_name(var);

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub impl mem_categorization_ctxt {
441441

442442
ast::expr_addr_of(*) | ast::expr_call(*) |
443443
ast::expr_swap(*) | ast::expr_assign(*) |
444-
ast::expr_assign_op(*) | ast::expr_fn(*) | ast::expr_fn_block(*) |
444+
ast::expr_assign_op(*) | ast::expr_fn_block(*) |
445445
ast::expr_assert(*) | ast::expr_ret(*) |
446446
ast::expr_loop_body(*) | ast::expr_do_body(*) |
447447
ast::expr_unary(*) | ast::expr_method_call(*) |

src/librustc/middle/moves.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,6 @@ pub impl VisitContext {
644644
self.use_expr(base, comp_mode, visitor);
645645
}
646646

647-
expr_fn(_, _, ref body, _) |
648647
expr_fn_block(_, ref body) => {
649648
let cap_vars = self.compute_captures(expr.id);
650649
self.move_maps.capture_map.insert(expr.id, cap_vars);

src/librustc/middle/resolve.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ use syntax::ast::{def_local, def_mod, def_prim_ty, def_region, def_self};
3434
use syntax::ast::{def_self_ty, def_static_method, def_struct, def_ty};
3535
use syntax::ast::{def_ty_param, def_typaram_binder};
3636
use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op};
37-
use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field, expr_fn};
37+
use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field};
3838
use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
3939
use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
4040
use syntax::ast::{def_upvar, def_use, def_variant, div, eq};
4141
use syntax::ast::{enum_variant_kind, expr, expr_again, expr_assign_op};
42-
use syntax::ast::{expr_fn_block, expr_index, expr_loop};
42+
use syntax::ast::{expr_index, expr_loop};
4343
use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl};
4444
use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge};
4545
use syntax::ast::{Generics};
@@ -4810,7 +4810,6 @@ pub impl Resolver {
48104810
visit_expr(expr, (), visitor);
48114811
}
48124812

4813-
expr_fn(_, ref fn_decl, ref block, _) |
48144813
expr_fn_block(ref fn_decl, ref block) => {
48154814
self.resolve_function(FunctionRibKind(expr.id, block.node.id),
48164815
Some(@/*bad*/copy *fn_decl),

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,12 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
869869
}
870870
ast_map::node_expr(expr) => {
871871
match /*bad*/copy expr.node {
872-
ast::expr_fn(_, decl, _, _) => {
873-
((dbg_cx.names)(~"fn"), decl.output, expr.id)
874-
}
875872
ast::expr_fn_block(decl, _) => {
876873
((dbg_cx.names)(~"fn"), decl.output, expr.id)
877874
}
878875
_ => fcx.ccx.sess.span_bug(expr.span,
879876
~"create_function: \
880-
expected an expr_fn or fn_block here")
877+
expected an expr_fn_block here")
881878
}
882879
}
883880
ast_map::node_dtor(_, _, did, _) => {

src/librustc/middle/trans/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
619619
ast::expr_vec(*) | ast::expr_repeat(*) => {
620620
return tvec::trans_fixed_vstore(bcx, expr, expr, dest);
621621
}
622-
ast::expr_fn(_, ref decl, ref body, _) |
623622
ast::expr_fn_block(ref decl, ref body) => {
624623
let expr_ty = expr_ty(bcx, expr);
625624
let sigil = ty::ty_closure_sigil(expr_ty);

src/librustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
301301
}
302302
}
303303
}
304-
expr_fn(*) | expr_fn_block(*) => {
304+
expr_fn_block(*) => {
305305
match ty::ty_closure_sigil(ty::expr_ty(cx.ccx.tcx, e)) {
306306
ast::OwnedSigil => {}
307307
ast::BorrowedSigil | ast::ManagedSigil => {

src/librustc/middle/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3124,7 +3124,6 @@ pub fn expr_kind(tcx: ctxt,
31243124
ast::expr_tup(*) |
31253125
ast::expr_if(*) |
31263126
ast::expr_match(*) |
3127-
ast::expr_fn(*) |
31283127
ast::expr_fn_block(*) |
31293128
ast::expr_loop_body(*) |
31303129
ast::expr_do_body(*) |

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,10 +2373,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23732373
ast::expr_match(discrim, ref arms) => {
23742374
bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms));
23752375
}
2376-
ast::expr_fn(sigil, ref decl, ref body, _) => {
2377-
check_expr_fn(fcx, expr, Some(sigil),
2378-
decl, body, Vanilla, expected);
2379-
}
23802376
ast::expr_fn_block(ref decl, ref body) => {
23812377
check_expr_fn(fcx, expr, None,
23822378
decl, body, Vanilla, expected);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) {
282282
guarantor::for_match(rcx, discr, *arms);
283283
}
284284

285-
ast::expr_fn(*) | ast::expr_fn_block(*) => {
285+
ast::expr_fn_block(*) => {
286286
let function_type = rcx.resolve_node_type(expr.id);
287287
match ty::get(function_type).sty {
288288
ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil,
@@ -708,7 +708,6 @@ pub mod guarantor {
708708
ast::expr_tup(*) |
709709
ast::expr_if(*) |
710710
ast::expr_match(*) |
711-
ast::expr_fn(*) |
712711
ast::expr_fn_block(*) |
713712
ast::expr_loop_body(*) |
714713
ast::expr_do_body(*) |

src/libsyntax/ast.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,6 @@ pub enum expr_ {
571571
(implicit) condition is always true. */
572572
expr_loop(blk, Option<ident>),
573573
expr_match(@expr, ~[arm]),
574-
575-
// FIXME(#4717) the @() is req'd on windows or else LLVM croaks
576-
expr_fn(Sigil, fn_decl, blk, @()),
577-
578574
expr_fn_block(fn_decl, blk),
579575
// Inner expr is always an expr_fn_block. We need the wrapping node to
580576
// easily type this (a function returning nil on the inside but bool on

src/libsyntax/ext/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* interface.
1616
*/
1717

18-
use prelude::*;
18+
use core::prelude::*;
1919

2020
use ast;
2121
use codemap::span;

src/libsyntax/ext/log_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use prelude::*;
1211
use core::io::WriterUtil;
12+
use core::prelude::*;
1313

1414
use ast;
1515
use codemap;

src/libsyntax/ext/trace_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use prelude::*;
11+
use core::prelude::*;
1212

1313
use ast::tt_delim;
1414
use ast;

src/libsyntax/fold.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,6 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
533533
arms.map(|x| fld.fold_arm(x))
534534
)
535535
}
536-
expr_fn(proto, ref decl, ref body, _) => {
537-
expr_fn(
538-
proto,
539-
fold_fn_decl(decl, fld),
540-
fld.fold_block(body),
541-
@()
542-
)
543-
}
544536
expr_fn_block(ref decl, ref body) => {
545537
expr_fn_block(
546538
fold_fn_decl(decl, fld),

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind};
2323
use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again};
2424
use ast::{expr_assert, expr_assign, expr_assign_op, expr_binary, expr_block};
2525
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
26-
use ast::{expr_field, expr_fn, expr_fn_block, expr_if, expr_index};
26+
use ast::{expr_field, expr_fn_block, expr_if, expr_index};
2727
use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
2828
use ast::{expr_method_call, expr_paren, expr_path, expr_rec, expr_repeat};
2929
use ast::{expr_ret, expr_swap, expr_struct, expr_tup, expr_unary};
@@ -381,17 +381,8 @@ pub impl Parser {
381381
let purity = self.parse_purity();
382382
let onceness = parse_onceness(&self);
383383
self.expect_keyword(&~"fn");
384-
let post_sigil = self.parse_fn_ty_sigil();
385-
386-
let sigil = match (pre_sigil, post_sigil) {
387-
(None, None) => BorrowedSigil,
388-
(Some(p), None) | (None, Some(p)) => p,
389-
(Some(_), Some(_)) => {
390-
self.fatal(~"cannot combine prefix and postfix \
391-
syntax for closure kind; note that \
392-
postfix syntax is obsolete");
393-
}
394-
};
384+
385+
let sigil = match pre_sigil { None => BorrowedSigil, Some(p) => p };
395386
396387
let region = if pre_region_name.is_some() {
397388
Some(self.region_from_name(pre_region_name))
@@ -1150,15 +1141,6 @@ pub impl Parser {
11501141
return self.parse_loop_expr();
11511142
} else if self.eat_keyword(&~"match") {
11521143
return self.parse_match_expr();
1153-
} else if self.eat_keyword(&~"fn") {
1154-
let opt_sigil = self.parse_fn_ty_sigil();
1155-
let sigil = match opt_sigil {
1156-
None => {
1157-
self.fatal(~"fn expr are deprecated, use fn@")
1158-
}
1159-
Some(p) => { p }
1160-
};
1161-
return self.parse_fn_expr(sigil);
11621144
} else if self.eat_keyword(&~"unsafe") {
11631145
return self.parse_block_expr(lo, unsafe_blk);
11641146
} else if *self.token == token::LBRACKET {
@@ -1775,19 +1757,6 @@ pub impl Parser {
17751757
self.mk_expr(lo, hi, expr_if(cond, thn, els))
17761758
}
17771759

1778-
fn parse_fn_expr(sigil: Sigil) -> @expr {
1779-
let lo = self.last_span.lo;
1780-
1781-
// if we want to allow fn expression argument types to be inferred in
1782-
// the future, just have to change parse_arg to parse_fn_block_arg.
1783-
let decl = self.parse_fn_decl(|p| p.parse_arg());
1784-
1785-
let body = self.parse_block();
1786-
1787-
self.mk_expr(lo, body.span.hi,
1788-
expr_fn(sigil, decl, body, @()))
1789-
}
1790-
17911760
// `|args| { ... }` like in `do` expressions
17921761
fn parse_lambda_block_expr() -> @expr {
17931762
self.parse_lambda_expr_(

src/libsyntax/print/pprust.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,17 +1346,6 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
13461346
}
13471347
bclose_(s, expr.span, match_indent_unit);
13481348
}
1349-
ast::expr_fn(sigil, ref decl, ref body, _) => {
1350-
// containing cbox, will be closed by print-block at }
1351-
cbox(s, indent_unit);
1352-
// head-box, will be closed by print-block at start
1353-
ibox(s, 0u);
1354-
print_fn_header_info(s, None, None, ast::Many,
1355-
Some(sigil), ast::inherited);
1356-
print_fn_args_and_ret(s, decl, None);
1357-
space(s.s);
1358-
print_block(s, body);
1359-
}
13601349
ast::expr_fn_block(ref decl, ref body) => {
13611350
// in do/for blocks we don't want to show an empty
13621351
// argument list, but at this point we don't know which

src/libsyntax/visit.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,6 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
534534
(v.visit_expr)(x, e, v);
535535
for arms.each |a| { (v.visit_arm)(a, e, v); }
536536
}
537-
expr_fn(proto, ref decl, ref body, _) => {
538-
(v.visit_fn)(
539-
&fk_anon(proto),
540-
decl,
541-
body,
542-
ex.span,
543-
ex.id,
544-
e,
545-
v
546-
);
547-
}
548537
expr_fn_block(ref decl, ref body) => {
549538
(v.visit_fn)(
550539
&fk_fn_block,

0 commit comments

Comments
 (0)