rustc: Merge fn& and fn in favor of fn&.
This is a step on the way to moving the function "proto" sigil out front.
This commit is contained in:
parent
51a5a4ad0e
commit
f23674394f
22 changed files with 33 additions and 44 deletions
|
|
@ -178,7 +178,6 @@ enum mutability { m_mutbl, m_imm, m_const, }
|
|||
#[auto_serialize]
|
||||
enum proto {
|
||||
proto_bare, // foreign fn
|
||||
proto_any, // fn
|
||||
proto_uniq, // fn~
|
||||
proto_box, // fn@
|
||||
proto_block, // fn&
|
||||
|
|
@ -195,7 +194,7 @@ enum vstore {
|
|||
|
||||
pure fn is_blockish(p: ast::proto) -> bool {
|
||||
alt p {
|
||||
proto_any | proto_block { true }
|
||||
proto_block { true }
|
||||
proto_bare | proto_uniq | proto_box { false }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,10 +186,10 @@ impl helpers of ext_ctxt_helpers for ext_ctxt {
|
|||
};
|
||||
|
||||
@{id: self.next_id(),
|
||||
node: ast::ty_fn(ast::proto_any, {inputs: args,
|
||||
output: output,
|
||||
purity: ast::impure_fn,
|
||||
cf: ast::return_val}),
|
||||
node: ast::ty_fn(ast::proto_block, {inputs: args,
|
||||
output: output,
|
||||
purity: ast::impure_fn,
|
||||
cf: ast::return_val}),
|
||||
span: span}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
|||
match_nonterminal, match_seq, match_tok, method, mode, mt, mul,
|
||||
mutability, neg, noreturn, not, pat, pat_box, pat_enum,
|
||||
pat_ident, pat_lit, pat_range, pat_rec, pat_tup, pat_uniq,
|
||||
pat_wild, path, private, proto, proto_any, proto_bare,
|
||||
proto_block, proto_box, proto_uniq, provided, public, pure_fn,
|
||||
purity, re_anon, re_named, region, rem, required, ret_style,
|
||||
return_val, self_ty, shl, shr, stmt, stmt_decl, stmt_expr,
|
||||
stmt_semi, subtract, sty_box, sty_by_ref, sty_region, sty_uniq,
|
||||
sty_value, token_tree, trait_method, trait_ref, tt_delim, tt_seq,
|
||||
tt_tok, tt_nonterminal, ty, ty_, ty_bot, ty_box, ty_field, ty_fn,
|
||||
pat_wild, path, private, proto, proto_bare, proto_block,
|
||||
proto_box, proto_uniq, provided, public, pure_fn, purity,
|
||||
re_anon, re_named, region, rem, required, ret_style, return_val,
|
||||
self_ty, shl, shr, stmt, stmt_decl, stmt_expr, stmt_semi,
|
||||
subtract, sty_box, sty_by_ref, sty_region, sty_uniq, sty_value,
|
||||
token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok,
|
||||
tt_nonterminal, ty, ty_, ty_bot, ty_box, ty_field, ty_fn,
|
||||
ty_infer, ty_mac, ty_method, ty_nil, ty_param, ty_path, ty_ptr,
|
||||
ty_rec, ty_rptr, ty_tup, ty_u32, ty_uniq, ty_vec,
|
||||
ty_fixed_length, unchecked_blk, uniq, unsafe_blk, unsafe_fn,
|
||||
|
|
@ -801,9 +801,6 @@ class parser {
|
|||
let proto = self.parse_fn_ty_proto();
|
||||
alt proto {
|
||||
proto_bare { self.fatal(~"fn expr are deprecated, use fn@"); }
|
||||
proto_any {
|
||||
self.fatal(~"fn* cannot be used in an expression");
|
||||
}
|
||||
_ { /* fallthrough */ }
|
||||
}
|
||||
return pexpr(self.parse_fn_expr(proto));
|
||||
|
|
@ -2781,7 +2778,7 @@ class parser {
|
|||
proto_block
|
||||
}
|
||||
_ {
|
||||
proto_any
|
||||
proto_block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1823,7 +1823,6 @@ fn print_purity(s: ps, p: ast::purity) {
|
|||
fn proto_to_str(p: ast::proto) -> ~str {
|
||||
return alt p {
|
||||
ast::proto_bare { ~"extern fn" }
|
||||
ast::proto_any { ~"fn" }
|
||||
ast::proto_block { ~"fn&" }
|
||||
ast::proto_uniq { ~"fn~" }
|
||||
ast::proto_box { ~"fn@" }
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ fn parse_proto(c: char) -> ast::proto {
|
|||
alt c {
|
||||
'~' { ast::proto_uniq }
|
||||
'@' { ast::proto_box }
|
||||
'*' { ast::proto_any }
|
||||
'&' { ast::proto_block }
|
||||
'n' { ast::proto_bare }
|
||||
_ { fail ~"illegal fn type kind " + str::from_char(c); }
|
||||
|
|
|
|||
|
|
@ -311,7 +311,6 @@ fn enc_proto(w: io::writer, proto: proto) {
|
|||
proto_uniq { w.write_str(&"f~"); }
|
||||
proto_box { w.write_str(&"f@"); }
|
||||
proto_block { w.write_str(~"f&"); }
|
||||
proto_any { w.write_str(&"f*"); }
|
||||
proto_bare { w.write_str(&"fn"); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ impl public_methods for borrowck_ctxt {
|
|||
let ty = ty::node_id_to_type(self.tcx, fn_node_id);
|
||||
let proto = ty::ty_fn_proto(ty);
|
||||
alt proto {
|
||||
ast::proto_any | ast::proto_block {
|
||||
ast::proto_block {
|
||||
let upcmt = self.cat_def(id, span, expr_ty, *inner);
|
||||
@{id:id, span:span,
|
||||
cat:cat_stack_upvar(upcmt), lp:upcmt.lp,
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ impl methods for check_loan_ctxt {
|
|||
let fn_ty = ty::node_id_to_type(self.tcx(), id);
|
||||
let proto = ty::ty_fn_proto(fn_ty);
|
||||
alt proto {
|
||||
ast::proto_block | ast::proto_any {true}
|
||||
ast::proto_block {true}
|
||||
ast::proto_bare | ast::proto_uniq | ast::proto_box {false}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
// named and add that
|
||||
|
||||
let implicit_mode = alt fn_proto {
|
||||
ast::proto_any | ast::proto_block { cap_ref }
|
||||
ast::proto_block { cap_ref }
|
||||
ast::proto_bare | ast::proto_box | ast::proto_uniq { cap_copy }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
|
|||
proto_uniq { b(check_for_uniq) }
|
||||
proto_box { b(check_for_box) }
|
||||
proto_bare { b(check_for_bare) }
|
||||
proto_any | proto_block { b(check_for_block) }
|
||||
proto_block { b(check_for_block) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ fn trans_expr_fn(bcx: block,
|
|||
};
|
||||
|
||||
let {bcx: bcx, val: closure} = alt proto {
|
||||
ast::proto_any | ast::proto_block { trans_closure_env(ty::ck_block) }
|
||||
ast::proto_block { trans_closure_env(ty::ck_block) }
|
||||
ast::proto_box { trans_closure_env(ty::ck_box) }
|
||||
ast::proto_uniq { trans_closure_env(ty::ck_uniq) }
|
||||
ast::proto_bare {
|
||||
|
|
@ -423,8 +423,7 @@ fn make_fn_glue(
|
|||
|
||||
return alt ty::get(t).struct {
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) |
|
||||
ty::ty_fn({proto: ast::proto_block, _}) |
|
||||
ty::ty_fn({proto: ast::proto_any, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_block, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) }
|
||||
ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) }
|
||||
_ { fail ~"make_fn_glue invoked on non-function type" }
|
||||
|
|
|
|||
|
|
@ -968,7 +968,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
|||
let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]);
|
||||
let fty = ty::mk_fn(bcx.tcx(), {
|
||||
purity: ast::impure_fn,
|
||||
proto: ast::proto_any,
|
||||
proto: ast::proto_block,
|
||||
inputs: ~[{
|
||||
mode: ast::expl(ast::by_val),
|
||||
ty: ty::mk_imm_ptr(
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ impl methods for reflector {
|
|||
};
|
||||
let protoval = alt fty.proto {
|
||||
ast::proto_bare { 0u }
|
||||
ast::proto_any { 1u }
|
||||
ast::proto_uniq { 2u }
|
||||
ast::proto_box { 3u }
|
||||
ast::proto_block { 4u }
|
||||
|
|
|
|||
|
|
@ -354,8 +354,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
}
|
||||
ty::ty_fn({proto: ast::proto_box, _}) { ~[shape_box_fn] }
|
||||
ty::ty_fn({proto: ast::proto_uniq, _}) { ~[shape_uniq_fn] }
|
||||
ty::ty_fn({proto: ast::proto_block, _}) |
|
||||
ty::ty_fn({proto: ast::proto_any, _}) { ~[shape_stack_fn] }
|
||||
ty::ty_fn({proto: ast::proto_block, _}) { ~[shape_stack_fn] }
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) { ~[shape_bare_fn] }
|
||||
ty::ty_opaque_closure_ptr(_) { ~[shape_opaque_closure_ptr] }
|
||||
ty::ty_var(_) | ty::ty_var_integral(_) | ty::ty_self {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
}
|
||||
expr_fn(*) | expr_fn_block(*) {
|
||||
alt ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) {
|
||||
proto_bare | proto_any | proto_uniq {}
|
||||
proto_bare | proto_uniq {}
|
||||
proto_box | proto_block {
|
||||
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
|
||||
let node_id = ast_util::def_id_of_def(fv.def).node;
|
||||
|
|
|
|||
|
|
@ -1291,7 +1291,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
ty_fn(fty) {
|
||||
alt fty.proto {
|
||||
proto_bare | proto_any | proto_block { false }
|
||||
proto_bare | proto_block { false }
|
||||
_ { true }
|
||||
}
|
||||
}
|
||||
|
|
@ -1533,7 +1533,6 @@ pure fn kind_is_owned(k: kind) -> bool {
|
|||
|
||||
fn proto_kind(p: proto) -> kind {
|
||||
alt p {
|
||||
ast::proto_any { kind_noncopyable() }
|
||||
ast::proto_block { kind_noncopyable() }
|
||||
ast::proto_box { kind_safe_for_default_mode() | kind_owned() }
|
||||
ast::proto_uniq { kind_send_copy() | kind_owned() }
|
||||
|
|
|
|||
|
|
@ -2396,7 +2396,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
|||
~"frame_address" {
|
||||
let fty = ty::mk_fn(ccx.tcx, {
|
||||
purity: ast::impure_fn,
|
||||
proto: ast::proto_any,
|
||||
proto: ast::proto_block,
|
||||
inputs: ~[{
|
||||
mode: ast::expl(ast::by_val),
|
||||
ty: ty::mk_imm_ptr(
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
tps: ty::ty_params_to_tys(tcx, tps)});
|
||||
let t_ctor = ty::mk_fn(
|
||||
tcx, {purity: ast::impure_fn,
|
||||
proto: ast::proto_any,
|
||||
proto: ast::proto_block,
|
||||
inputs: t_args,
|
||||
output: t_res,
|
||||
ret_style: ast::return_val});
|
||||
|
|
@ -410,7 +410,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
// Write the dtor type
|
||||
let t_dtor = ty::mk_fn(
|
||||
tcx,
|
||||
ty_of_fn_decl(ccx, type_rscope(rp), ast::proto_any,
|
||||
ty_of_fn_decl(ccx, type_rscope(rp), ast::proto_block,
|
||||
ast_util::dtor_dec(), none));
|
||||
write_ty_to_tcx(tcx, dtor.node.id, t_dtor);
|
||||
tcx.tcache.insert(local_def(dtor.node.id),
|
||||
|
|
|
|||
|
|
@ -2120,7 +2120,7 @@ impl of combine for lub {
|
|||
} else if p1 == p2 {
|
||||
ok(p1)
|
||||
} else {
|
||||
ok(ast::proto_any)
|
||||
ok(ast::proto_block)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2314,9 +2314,9 @@ impl of combine for glb {
|
|||
}
|
||||
|
||||
fn protos(p1: ast::proto, p2: ast::proto) -> cres<ast::proto> {
|
||||
if p1 == ast::proto_any {
|
||||
if p1 == ast::proto_block {
|
||||
ok(p2)
|
||||
} else if p2 == ast::proto_any {
|
||||
} else if p2 == ast::proto_block {
|
||||
ok(p1)
|
||||
} else if p1 == p2 {
|
||||
ok(p1)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ fn coerce(b: fn()) -> extern fn() {
|
|||
g: fn()) -> extern fn() { return f(g); }
|
||||
fn fn_id(f: extern fn()) -> extern fn() { return f }
|
||||
return lol(fn_id, b);
|
||||
//~^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
|
||||
//~^ ERROR mismatched types: expected `extern fn(fn&()) -> extern fn()`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// error-pattern:expected `fn()` but found `*u8`
|
||||
// error-pattern:expected `fn&()` but found `*u8`
|
||||
extern fn f() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// extern functions are *u8 types
|
||||
let _x: fn() = f;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ fn foo(f: fn()) { f() }
|
|||
|
||||
fn main() {
|
||||
~"" || 42; //~ ERROR binary operation || cannot be applied to type `~str`
|
||||
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())`
|
||||
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn&())`
|
||||
//~^ NOTE did you forget the 'do' keyword for the call?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue