Skip to content

Commit f236743

Browse files
committed
rustc: Merge fn& and fn in favor of fn&.
This is a step on the way to moving the function "proto" sigil out front.
1 parent 51a5a4a commit f236743

22 files changed

+33
-44
lines changed

src/libsyntax/ast.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ enum mutability { m_mutbl, m_imm, m_const, }
178178
#[auto_serialize]
179179
enum proto {
180180
proto_bare, // foreign fn
181-
proto_any, // fn
182181
proto_uniq, // fn~
183182
proto_box, // fn@
184183
proto_block, // fn&
@@ -195,7 +194,7 @@ enum vstore {
195194

196195
pure fn is_blockish(p: ast::proto) -> bool {
197196
alt p {
198-
proto_any | proto_block { true }
197+
proto_block { true }
199198
proto_bare | proto_uniq | proto_box { false }
200199
}
201200
}

src/libsyntax/ext/auto_serialize.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ impl helpers of ext_ctxt_helpers for ext_ctxt {
186186
};
187187

188188
@{id: self.next_id(),
189-
node: ast::ty_fn(ast::proto_any, {inputs: args,
190-
output: output,
191-
purity: ast::impure_fn,
192-
cf: ast::return_val}),
189+
node: ast::ty_fn(ast::proto_block, {inputs: args,
190+
output: output,
191+
purity: ast::impure_fn,
192+
cf: ast::return_val}),
193193
span: span}
194194
}
195195

src/libsyntax/parse/parser.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
4141
match_nonterminal, match_seq, match_tok, method, mode, mt, mul,
4242
mutability, neg, noreturn, not, pat, pat_box, pat_enum,
4343
pat_ident, pat_lit, pat_range, pat_rec, pat_tup, pat_uniq,
44-
pat_wild, path, private, proto, proto_any, proto_bare,
45-
proto_block, proto_box, proto_uniq, provided, public, pure_fn,
46-
purity, re_anon, re_named, region, rem, required, ret_style,
47-
return_val, self_ty, shl, shr, stmt, stmt_decl, stmt_expr,
48-
stmt_semi, subtract, sty_box, sty_by_ref, sty_region, sty_uniq,
49-
sty_value, token_tree, trait_method, trait_ref, tt_delim, tt_seq,
50-
tt_tok, tt_nonterminal, ty, ty_, ty_bot, ty_box, ty_field, ty_fn,
44+
pat_wild, path, private, proto, proto_bare, proto_block,
45+
proto_box, proto_uniq, provided, public, pure_fn, purity,
46+
re_anon, re_named, region, rem, required, ret_style, return_val,
47+
self_ty, shl, shr, stmt, stmt_decl, stmt_expr, stmt_semi,
48+
subtract, sty_box, sty_by_ref, sty_region, sty_uniq, sty_value,
49+
token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok,
50+
tt_nonterminal, ty, ty_, ty_bot, ty_box, ty_field, ty_fn,
5151
ty_infer, ty_mac, ty_method, ty_nil, ty_param, ty_path, ty_ptr,
5252
ty_rec, ty_rptr, ty_tup, ty_u32, ty_uniq, ty_vec,
5353
ty_fixed_length, unchecked_blk, uniq, unsafe_blk, unsafe_fn,
@@ -801,9 +801,6 @@ class parser {
801801
let proto = self.parse_fn_ty_proto();
802802
alt proto {
803803
proto_bare { self.fatal(~"fn expr are deprecated, use fn@"); }
804-
proto_any {
805-
self.fatal(~"fn* cannot be used in an expression");
806-
}
807804
_ { /* fallthrough */ }
808805
}
809806
return pexpr(self.parse_fn_expr(proto));
@@ -2781,7 +2778,7 @@ class parser {
27812778
proto_block
27822779
}
27832780
_ {
2784-
proto_any
2781+
proto_block
27852782
}
27862783
}
27872784
}

src/libsyntax/print/pprust.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,6 @@ fn print_purity(s: ps, p: ast::purity) {
18231823
fn proto_to_str(p: ast::proto) -> ~str {
18241824
return alt p {
18251825
ast::proto_bare { ~"extern fn" }
1826-
ast::proto_any { ~"fn" }
18271826
ast::proto_block { ~"fn&" }
18281827
ast::proto_uniq { ~"fn~" }
18291828
ast::proto_box { ~"fn@" }

src/rustc/metadata/tydecode.rs

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ fn parse_proto(c: char) -> ast::proto {
8989
alt c {
9090
'~' { ast::proto_uniq }
9191
'@' { ast::proto_box }
92-
'*' { ast::proto_any }
9392
'&' { ast::proto_block }
9493
'n' { ast::proto_bare }
9594
_ { fail ~"illegal fn type kind " + str::from_char(c); }

src/rustc/metadata/tyencode.rs

-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ fn enc_proto(w: io::writer, proto: proto) {
311311
proto_uniq { w.write_str(&"f~"); }
312312
proto_box { w.write_str(&"f@"); }
313313
proto_block { w.write_str(~"f&"); }
314-
proto_any { w.write_str(&"f*"); }
315314
proto_bare { w.write_str(&"fn"); }
316315
}
317316
}

src/rustc/middle/borrowck/categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl public_methods for borrowck_ctxt {
244244
let ty = ty::node_id_to_type(self.tcx, fn_node_id);
245245
let proto = ty::ty_fn_proto(ty);
246246
alt proto {
247-
ast::proto_any | ast::proto_block {
247+
ast::proto_block {
248248
let upcmt = self.cat_def(id, span, expr_ty, *inner);
249249
@{id:id, span:span,
250250
cat:cat_stack_upvar(upcmt), lp:upcmt.lp,

src/rustc/middle/borrowck/check_loans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl methods for check_loan_ctxt {
220220
let fn_ty = ty::node_id_to_type(self.tcx(), id);
221221
let proto = ty::ty_fn_proto(fn_ty);
222222
alt proto {
223-
ast::proto_block | ast::proto_any {true}
223+
ast::proto_block {true}
224224
ast::proto_bare | ast::proto_uniq | ast::proto_box {false}
225225
}
226226
}

src/rustc/middle/capture.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
102102
// named and add that
103103

104104
let implicit_mode = alt fn_proto {
105-
ast::proto_any | ast::proto_block { cap_ref }
105+
ast::proto_block { cap_ref }
106106
ast::proto_bare | ast::proto_box | ast::proto_uniq { cap_copy }
107107
};
108108

src/rustc/middle/kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
148148
proto_uniq { b(check_for_uniq) }
149149
proto_box { b(check_for_box) }
150150
proto_bare { b(check_for_bare) }
151-
proto_any | proto_block { b(check_for_block) }
151+
proto_block { b(check_for_block) }
152152
}
153153
}
154154

src/rustc/middle/trans/closure.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fn trans_expr_fn(bcx: block,
388388
};
389389

390390
let {bcx: bcx, val: closure} = alt proto {
391-
ast::proto_any | ast::proto_block { trans_closure_env(ty::ck_block) }
391+
ast::proto_block { trans_closure_env(ty::ck_block) }
392392
ast::proto_box { trans_closure_env(ty::ck_box) }
393393
ast::proto_uniq { trans_closure_env(ty::ck_uniq) }
394394
ast::proto_bare {
@@ -423,8 +423,7 @@ fn make_fn_glue(
423423

424424
return alt ty::get(t).struct {
425425
ty::ty_fn({proto: ast::proto_bare, _}) |
426-
ty::ty_fn({proto: ast::proto_block, _}) |
427-
ty::ty_fn({proto: ast::proto_any, _}) { bcx }
426+
ty::ty_fn({proto: ast::proto_block, _}) { bcx }
428427
ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) }
429428
ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) }
430429
_ { fail ~"make_fn_glue invoked on non-function type" }

src/rustc/middle/trans/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
968968
let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]);
969969
let fty = ty::mk_fn(bcx.tcx(), {
970970
purity: ast::impure_fn,
971-
proto: ast::proto_any,
971+
proto: ast::proto_block,
972972
inputs: ~[{
973973
mode: ast::expl(ast::by_val),
974974
ty: ty::mk_imm_ptr(

src/rustc/middle/trans/reflect.rs

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ impl methods for reflector {
186186
};
187187
let protoval = alt fty.proto {
188188
ast::proto_bare { 0u }
189-
ast::proto_any { 1u }
190189
ast::proto_uniq { 2u }
191190
ast::proto_box { 3u }
192191
ast::proto_block { 4u }

src/rustc/middle/trans/shape.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
354354
}
355355
ty::ty_fn({proto: ast::proto_box, _}) { ~[shape_box_fn] }
356356
ty::ty_fn({proto: ast::proto_uniq, _}) { ~[shape_uniq_fn] }
357-
ty::ty_fn({proto: ast::proto_block, _}) |
358-
ty::ty_fn({proto: ast::proto_any, _}) { ~[shape_stack_fn] }
357+
ty::ty_fn({proto: ast::proto_block, _}) { ~[shape_stack_fn] }
359358
ty::ty_fn({proto: ast::proto_bare, _}) { ~[shape_bare_fn] }
360359
ty::ty_opaque_closure_ptr(_) { ~[shape_opaque_closure_ptr] }
361360
ty::ty_var(_) | ty::ty_var_integral(_) | ty::ty_self {

src/rustc/middle/trans/type_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
192192
}
193193
expr_fn(*) | expr_fn_block(*) {
194194
alt ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) {
195-
proto_bare | proto_any | proto_uniq {}
195+
proto_bare | proto_uniq {}
196196
proto_box | proto_block {
197197
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
198198
let node_id = ast_util::def_id_of_def(fv.def).node;

src/rustc/middle/ty.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
12911291
}
12921292
ty_fn(fty) {
12931293
alt fty.proto {
1294-
proto_bare | proto_any | proto_block { false }
1294+
proto_bare | proto_block { false }
12951295
_ { true }
12961296
}
12971297
}
@@ -1533,7 +1533,6 @@ pure fn kind_is_owned(k: kind) -> bool {
15331533

15341534
fn proto_kind(p: proto) -> kind {
15351535
alt p {
1536-
ast::proto_any { kind_noncopyable() }
15371536
ast::proto_block { kind_noncopyable() }
15381537
ast::proto_box { kind_safe_for_default_mode() | kind_owned() }
15391538
ast::proto_uniq { kind_send_copy() | kind_owned() }

src/rustc/middle/typeck/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
23962396
~"frame_address" {
23972397
let fty = ty::mk_fn(ccx.tcx, {
23982398
purity: ast::impure_fn,
2399-
proto: ast::proto_any,
2399+
proto: ast::proto_block,
24002400
inputs: ~[{
24012401
mode: ast::expl(ast::by_val),
24022402
ty: ty::mk_imm_ptr(

src/rustc/middle/typeck/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
395395
tps: ty::ty_params_to_tys(tcx, tps)});
396396
let t_ctor = ty::mk_fn(
397397
tcx, {purity: ast::impure_fn,
398-
proto: ast::proto_any,
398+
proto: ast::proto_block,
399399
inputs: t_args,
400400
output: t_res,
401401
ret_style: ast::return_val});
@@ -410,7 +410,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
410410
// Write the dtor type
411411
let t_dtor = ty::mk_fn(
412412
tcx,
413-
ty_of_fn_decl(ccx, type_rscope(rp), ast::proto_any,
413+
ty_of_fn_decl(ccx, type_rscope(rp), ast::proto_block,
414414
ast_util::dtor_dec(), none));
415415
write_ty_to_tcx(tcx, dtor.node.id, t_dtor);
416416
tcx.tcache.insert(local_def(dtor.node.id),

src/rustc/middle/typeck/infer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ impl of combine for lub {
21202120
} else if p1 == p2 {
21212121
ok(p1)
21222122
} else {
2123-
ok(ast::proto_any)
2123+
ok(ast::proto_block)
21242124
}
21252125
}
21262126

@@ -2314,9 +2314,9 @@ impl of combine for glb {
23142314
}
23152315

23162316
fn protos(p1: ast::proto, p2: ast::proto) -> cres<ast::proto> {
2317-
if p1 == ast::proto_any {
2317+
if p1 == ast::proto_block {
23182318
ok(p2)
2319-
} else if p2 == ast::proto_any {
2319+
} else if p2 == ast::proto_block {
23202320
ok(p1)
23212321
} else if p1 == p2 {
23222322
ok(p1)

src/test/compile-fail/block-coerce-no.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn coerce(b: fn()) -> extern fn() {
66
g: fn()) -> extern fn() { return f(g); }
77
fn fn_id(f: extern fn()) -> extern fn() { return f }
88
return lol(fn_id, b);
9-
//~^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
9+
//~^ ERROR mismatched types: expected `extern fn(fn&()) -> extern fn()`
1010
}
1111

1212
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// error-pattern:expected `fn()` but found `*u8`
1+
// error-pattern:expected `fn&()` but found `*u8`
22
extern fn f() {
33
}
44

55
fn main() {
66
// extern functions are *u8 types
77
let _x: fn() = f;
8-
}
8+
}

src/test/compile-fail/missing-do.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ fn foo(f: fn()) { f() }
44

55
fn main() {
66
~"" || 42; //~ ERROR binary operation || cannot be applied to type `~str`
7-
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())`
7+
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn&())`
88
//~^ NOTE did you forget the 'do' keyword for the call?
99
}

0 commit comments

Comments
 (0)