librustc: Stop parsing fn@
, fn~
, and fn&
This commit is contained in:
parent
ce3b17badd
commit
ccec510f39
@ -212,8 +212,8 @@ pub impl CheckLoanCtxt {
|
||||
(*self.fn_args).contains(&(did.node));
|
||||
if is_fn_arg { return; } // case (a) above
|
||||
}
|
||||
ast::expr_fn_block(*) | ast::expr_fn(*) |
|
||||
ast::expr_loop_body(*) | ast::expr_do_body(*) => {
|
||||
ast::expr_fn_block(*) | ast::expr_loop_body(*) |
|
||||
ast::expr_do_body(*) => {
|
||||
if self.is_stack_closure(expr.id) {
|
||||
// case (b) above
|
||||
return;
|
||||
@ -244,7 +244,7 @@ pub impl CheckLoanCtxt {
|
||||
}
|
||||
|
||||
// True if the expression with the given `id` is a stack closure.
|
||||
// The expression must be an expr_fn(*) or expr_fn_block(*)
|
||||
// The expression must be an expr_fn_block(*)
|
||||
fn is_stack_closure(@mut self, id: ast::node_id) -> bool {
|
||||
let fn_ty = ty::node_id_to_type(self.tcx(), id);
|
||||
match ty::get(fn_ty).sty {
|
||||
@ -262,10 +262,8 @@ pub impl CheckLoanCtxt {
|
||||
did.crate == ast::local_crate &&
|
||||
(*self.fn_args).contains(&(did.node))
|
||||
}
|
||||
ast::expr_fn_block(*) | ast::expr_fn(*) => {
|
||||
self.is_stack_closure(expr.id)
|
||||
}
|
||||
_ => false
|
||||
ast::expr_fn_block(*) => self.is_stack_closure(expr.id),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
||||
expr_loop(ref b, _) => {
|
||||
(v.visit_block)(b, Context { in_loop: true,.. cx }, v);
|
||||
}
|
||||
expr_fn(*) => {
|
||||
visit::visit_expr(e, Context {
|
||||
in_loop: false,
|
||||
can_ret: true
|
||||
}, v);
|
||||
}
|
||||
expr_fn_block(_, ref b) => {
|
||||
(v.visit_block)(b, Context {
|
||||
in_loop: false,
|
||||
|
@ -49,12 +49,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
|
||||
let walk_expr: @fn(expr: @ast::expr, &&depth: int, v: visit::vt<int>) =
|
||||
|expr, depth, v| {
|
||||
match expr.node {
|
||||
ast::expr_fn(_, _, _, _) => {
|
||||
visit::visit_expr(expr, depth + 1, v);
|
||||
}
|
||||
ast::expr_fn_block(*) => {
|
||||
visit::visit_expr(expr, depth + 1, v);
|
||||
}
|
||||
ast::expr_fn_block(*) => visit::visit_expr(expr, depth + 1, v),
|
||||
ast::expr_path(*) => {
|
||||
let mut i = 0;
|
||||
match def_map.find(&expr.id) {
|
||||
|
@ -570,7 +570,6 @@ fn visit_expr(expr: @expr, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
|
||||
}
|
||||
visit::visit_expr(expr, self, vt);
|
||||
}
|
||||
expr_fn(*) |
|
||||
expr_fn_block(*) => {
|
||||
// Interesting control flow (for loops can contain labeled
|
||||
// breaks or continues)
|
||||
@ -1123,8 +1122,8 @@ pub impl Liveness {
|
||||
self.propagate_through_expr(e, succ)
|
||||
}
|
||||
|
||||
expr_fn(_, _, ref blk, _) | expr_fn_block(_, ref blk) => {
|
||||
debug!("%s is an expr_fn or expr_fn_block",
|
||||
expr_fn_block(_, ref blk) => {
|
||||
debug!("%s is an expr_fn_block",
|
||||
expr_to_str(expr, self.tcx.sess.intr()));
|
||||
|
||||
/*
|
||||
@ -1592,7 +1591,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
|
||||
visit::visit_expr(expr, self, vt);
|
||||
}
|
||||
|
||||
expr_fn(*) | expr_fn_block(*) => {
|
||||
expr_fn_block(*) => {
|
||||
let caps = self.ir.captures(expr);
|
||||
for caps.each |cap| {
|
||||
let var = self.variable(cap.var_nid, expr.span);
|
||||
@ -1794,7 +1793,7 @@ pub impl @Liveness {
|
||||
}
|
||||
|
||||
match move_expr.node {
|
||||
expr_fn(*) | expr_fn_block(*) => {
|
||||
expr_fn_block(*) => {
|
||||
self.report_illegal_read(
|
||||
move_expr.span, lnk, var, MovedValue);
|
||||
let name = self.ir.variable_name(var);
|
||||
|
@ -441,7 +441,7 @@ pub impl mem_categorization_ctxt {
|
||||
|
||||
ast::expr_addr_of(*) | ast::expr_call(*) |
|
||||
ast::expr_swap(*) | ast::expr_assign(*) |
|
||||
ast::expr_assign_op(*) | ast::expr_fn(*) | ast::expr_fn_block(*) |
|
||||
ast::expr_assign_op(*) | ast::expr_fn_block(*) |
|
||||
ast::expr_assert(*) | ast::expr_ret(*) |
|
||||
ast::expr_loop_body(*) | ast::expr_do_body(*) |
|
||||
ast::expr_unary(*) | ast::expr_method_call(*) |
|
||||
|
@ -644,7 +644,6 @@ pub impl VisitContext {
|
||||
self.use_expr(base, comp_mode, visitor);
|
||||
}
|
||||
|
||||
expr_fn(_, _, ref body, _) |
|
||||
expr_fn_block(_, ref body) => {
|
||||
let cap_vars = self.compute_captures(expr.id);
|
||||
self.move_maps.capture_map.insert(expr.id, cap_vars);
|
||||
|
@ -34,12 +34,12 @@ use syntax::ast::{def_local, def_mod, def_prim_ty, def_region, def_self};
|
||||
use syntax::ast::{def_self_ty, def_static_method, def_struct, def_ty};
|
||||
use syntax::ast::{def_ty_param, def_typaram_binder};
|
||||
use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op};
|
||||
use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field, expr_fn};
|
||||
use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field};
|
||||
use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
|
||||
use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
|
||||
use syntax::ast::{def_upvar, def_use, def_variant, div, eq};
|
||||
use syntax::ast::{enum_variant_kind, expr, expr_again, expr_assign_op};
|
||||
use syntax::ast::{expr_fn_block, expr_index, expr_loop};
|
||||
use syntax::ast::{expr_index, expr_loop};
|
||||
use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl};
|
||||
use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge};
|
||||
use syntax::ast::{Generics};
|
||||
@ -4810,7 +4810,6 @@ pub impl Resolver {
|
||||
visit_expr(expr, (), visitor);
|
||||
}
|
||||
|
||||
expr_fn(_, ref fn_decl, ref block, _) |
|
||||
expr_fn_block(ref fn_decl, ref block) => {
|
||||
self.resolve_function(FunctionRibKind(expr.id, block.node.id),
|
||||
Some(@/*bad*/copy *fn_decl),
|
||||
|
@ -869,15 +869,12 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
|
||||
}
|
||||
ast_map::node_expr(expr) => {
|
||||
match /*bad*/copy expr.node {
|
||||
ast::expr_fn(_, decl, _, _) => {
|
||||
((dbg_cx.names)(~"fn"), decl.output, expr.id)
|
||||
}
|
||||
ast::expr_fn_block(decl, _) => {
|
||||
((dbg_cx.names)(~"fn"), decl.output, expr.id)
|
||||
}
|
||||
_ => fcx.ccx.sess.span_bug(expr.span,
|
||||
~"create_function: \
|
||||
expected an expr_fn or fn_block here")
|
||||
expected an expr_fn_block here")
|
||||
}
|
||||
}
|
||||
ast_map::node_dtor(_, _, did, _) => {
|
||||
|
@ -619,7 +619,6 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
|
||||
ast::expr_vec(*) | ast::expr_repeat(*) => {
|
||||
return tvec::trans_fixed_vstore(bcx, expr, expr, dest);
|
||||
}
|
||||
ast::expr_fn(_, ref decl, ref body, _) |
|
||||
ast::expr_fn_block(ref decl, ref body) => {
|
||||
let expr_ty = expr_ty(bcx, expr);
|
||||
let sigil = ty::ty_closure_sigil(expr_ty);
|
||||
|
@ -301,7 +301,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
expr_fn(*) | expr_fn_block(*) => {
|
||||
expr_fn_block(*) => {
|
||||
match ty::ty_closure_sigil(ty::expr_ty(cx.ccx.tcx, e)) {
|
||||
ast::OwnedSigil => {}
|
||||
ast::BorrowedSigil | ast::ManagedSigil => {
|
||||
|
@ -3124,7 +3124,6 @@ pub fn expr_kind(tcx: ctxt,
|
||||
ast::expr_tup(*) |
|
||||
ast::expr_if(*) |
|
||||
ast::expr_match(*) |
|
||||
ast::expr_fn(*) |
|
||||
ast::expr_fn_block(*) |
|
||||
ast::expr_loop_body(*) |
|
||||
ast::expr_do_body(*) |
|
||||
|
@ -2373,10 +2373,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||
ast::expr_match(discrim, ref arms) => {
|
||||
bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms));
|
||||
}
|
||||
ast::expr_fn(sigil, ref decl, ref body, _) => {
|
||||
check_expr_fn(fcx, expr, Some(sigil),
|
||||
decl, body, Vanilla, expected);
|
||||
}
|
||||
ast::expr_fn_block(ref decl, ref body) => {
|
||||
check_expr_fn(fcx, expr, None,
|
||||
decl, body, Vanilla, expected);
|
||||
|
@ -282,7 +282,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) {
|
||||
guarantor::for_match(rcx, discr, *arms);
|
||||
}
|
||||
|
||||
ast::expr_fn(*) | ast::expr_fn_block(*) => {
|
||||
ast::expr_fn_block(*) => {
|
||||
let function_type = rcx.resolve_node_type(expr.id);
|
||||
match ty::get(function_type).sty {
|
||||
ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil,
|
||||
@ -708,7 +708,6 @@ pub mod guarantor {
|
||||
ast::expr_tup(*) |
|
||||
ast::expr_if(*) |
|
||||
ast::expr_match(*) |
|
||||
ast::expr_fn(*) |
|
||||
ast::expr_fn_block(*) |
|
||||
ast::expr_loop_body(*) |
|
||||
ast::expr_do_body(*) |
|
||||
|
@ -571,10 +571,6 @@ pub enum expr_ {
|
||||
(implicit) condition is always true. */
|
||||
expr_loop(blk, Option<ident>),
|
||||
expr_match(@expr, ~[arm]),
|
||||
|
||||
// FIXME(#4717) the @() is req'd on windows or else LLVM croaks
|
||||
expr_fn(Sigil, fn_decl, blk, @()),
|
||||
|
||||
expr_fn_block(fn_decl, blk),
|
||||
// Inner expr is always an expr_fn_block. We need the wrapping node to
|
||||
// easily type this (a function returning nil on the inside but bool on
|
||||
|
@ -15,7 +15,7 @@
|
||||
* interface.
|
||||
*/
|
||||
|
||||
use prelude::*;
|
||||
use core::prelude::*;
|
||||
|
||||
use ast;
|
||||
use codemap::span;
|
||||
|
@ -8,8 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use prelude::*;
|
||||
use core::io::WriterUtil;
|
||||
use core::prelude::*;
|
||||
|
||||
use ast;
|
||||
use codemap;
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use prelude::*;
|
||||
use core::prelude::*;
|
||||
|
||||
use ast::tt_delim;
|
||||
use ast;
|
||||
|
@ -533,14 +533,6 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
|
||||
arms.map(|x| fld.fold_arm(x))
|
||||
)
|
||||
}
|
||||
expr_fn(proto, ref decl, ref body, _) => {
|
||||
expr_fn(
|
||||
proto,
|
||||
fold_fn_decl(decl, fld),
|
||||
fld.fold_block(body),
|
||||
@()
|
||||
)
|
||||
}
|
||||
expr_fn_block(ref decl, ref body) => {
|
||||
expr_fn_block(
|
||||
fold_fn_decl(decl, fld),
|
||||
|
@ -23,7 +23,7 @@ use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind};
|
||||
use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again};
|
||||
use ast::{expr_assert, expr_assign, expr_assign_op, expr_binary, expr_block};
|
||||
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
|
||||
use ast::{expr_field, expr_fn, expr_fn_block, expr_if, expr_index};
|
||||
use ast::{expr_field, expr_fn_block, expr_if, expr_index};
|
||||
use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
|
||||
use ast::{expr_method_call, expr_paren, expr_path, expr_rec, expr_repeat};
|
||||
use ast::{expr_ret, expr_swap, expr_struct, expr_tup, expr_unary};
|
||||
@ -381,17 +381,8 @@ pub impl Parser {
|
||||
let purity = self.parse_purity();
|
||||
let onceness = parse_onceness(&self);
|
||||
self.expect_keyword(&~"fn");
|
||||
let post_sigil = self.parse_fn_ty_sigil();
|
||||
|
||||
let sigil = match (pre_sigil, post_sigil) {
|
||||
(None, None) => BorrowedSigil,
|
||||
(Some(p), None) | (None, Some(p)) => p,
|
||||
(Some(_), Some(_)) => {
|
||||
self.fatal(~"cannot combine prefix and postfix \
|
||||
syntax for closure kind; note that \
|
||||
postfix syntax is obsolete");
|
||||
}
|
||||
};
|
||||
let sigil = match pre_sigil { None => BorrowedSigil, Some(p) => p };
|
||||
|
||||
let region = if pre_region_name.is_some() {
|
||||
Some(self.region_from_name(pre_region_name))
|
||||
@ -1150,15 +1141,6 @@ pub impl Parser {
|
||||
return self.parse_loop_expr();
|
||||
} else if self.eat_keyword(&~"match") {
|
||||
return self.parse_match_expr();
|
||||
} else if self.eat_keyword(&~"fn") {
|
||||
let opt_sigil = self.parse_fn_ty_sigil();
|
||||
let sigil = match opt_sigil {
|
||||
None => {
|
||||
self.fatal(~"fn expr are deprecated, use fn@")
|
||||
}
|
||||
Some(p) => { p }
|
||||
};
|
||||
return self.parse_fn_expr(sigil);
|
||||
} else if self.eat_keyword(&~"unsafe") {
|
||||
return self.parse_block_expr(lo, unsafe_blk);
|
||||
} else if *self.token == token::LBRACKET {
|
||||
@ -1775,19 +1757,6 @@ pub impl Parser {
|
||||
self.mk_expr(lo, hi, expr_if(cond, thn, els))
|
||||
}
|
||||
|
||||
fn parse_fn_expr(sigil: Sigil) -> @expr {
|
||||
let lo = self.last_span.lo;
|
||||
|
||||
// if we want to allow fn expression argument types to be inferred in
|
||||
// the future, just have to change parse_arg to parse_fn_block_arg.
|
||||
let decl = self.parse_fn_decl(|p| p.parse_arg());
|
||||
|
||||
let body = self.parse_block();
|
||||
|
||||
self.mk_expr(lo, body.span.hi,
|
||||
expr_fn(sigil, decl, body, @()))
|
||||
}
|
||||
|
||||
// `|args| { ... }` like in `do` expressions
|
||||
fn parse_lambda_block_expr() -> @expr {
|
||||
self.parse_lambda_expr_(
|
||||
|
@ -1346,17 +1346,6 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
||||
}
|
||||
bclose_(s, expr.span, match_indent_unit);
|
||||
}
|
||||
ast::expr_fn(sigil, ref decl, ref body, _) => {
|
||||
// containing cbox, will be closed by print-block at }
|
||||
cbox(s, indent_unit);
|
||||
// head-box, will be closed by print-block at start
|
||||
ibox(s, 0u);
|
||||
print_fn_header_info(s, None, None, ast::Many,
|
||||
Some(sigil), ast::inherited);
|
||||
print_fn_args_and_ret(s, decl, None);
|
||||
space(s.s);
|
||||
print_block(s, body);
|
||||
}
|
||||
ast::expr_fn_block(ref decl, ref body) => {
|
||||
// in do/for blocks we don't want to show an empty
|
||||
// argument list, but at this point we don't know which
|
||||
|
@ -534,17 +534,6 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
(v.visit_expr)(x, e, v);
|
||||
for arms.each |a| { (v.visit_arm)(a, e, v); }
|
||||
}
|
||||
expr_fn(proto, ref decl, ref body, _) => {
|
||||
(v.visit_fn)(
|
||||
&fk_anon(proto),
|
||||
decl,
|
||||
body,
|
||||
ex.span,
|
||||
ex.id,
|
||||
e,
|
||||
v
|
||||
);
|
||||
}
|
||||
expr_fn_block(ref decl, ref body) => {
|
||||
(v.visit_fn)(
|
||||
&fk_fn_block,
|
||||
|
Loading…
x
Reference in New Issue
Block a user