Skip to content

librustc: Make the default sigil for block lambdas & instead of @. #4418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcore/task/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
};
if result {
// Unwinding function in case any ancestral enlisting fails
let bail = |tg: TaskGroupInner| {
let bail: @fn(TaskGroupInner) = |tg| {
leave_taskgroup(tg, child, false)
};
// Attempt to join every ancestor group.
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export encode_def_id;

type abbrev_map = map::HashMap<ty::t, tyencode::ty_abbrev>;

type encode_inlined_item = fn@(ecx: @encode_ctxt,
ebml_w: writer::Encoder,
path: ast_map::path,
ii: ast::inlined_item);
pub type encode_inlined_item = fn@(ecx: @encode_ctxt,
ebml_w: writer::Encoder,
path: ast_map::path,
ii: ast::inlined_item);

type encode_parms = {
diag: span_handler,
Expand Down Expand Up @@ -571,7 +571,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
index: @mut ~[entry<int>]) {
index.push({val: item.id, pos: ebml_w.writer.tell()});
}
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
let add_to_index: &fn() = || add_to_index_(item, ebml_w, index);

debug!("encoding info for item at %s",
ecx.tcx.sess.codemap.span_to_str(item.span));
Expand Down
12 changes: 8 additions & 4 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ use syntax::ast_map::{node_item, node_method};
use syntax::ast_map;
use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local};
use syntax::ast_util::{visibility_to_privacy};
use syntax::codemap::span;
use syntax::visit;

fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
let privileged_items = @DVec();
let legacy_exports = has_legacy_export_attr(crate.node.attrs);

// Adds structs that are privileged to this scope.
let add_privileged_items = |items: &[@ast::item]| {
let add_privileged_items: @fn(&[@ast::item]) -> int = |items| {
let mut count = 0;
for items.each |item| {
match item.node {
Expand All @@ -53,7 +54,8 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
};

// Checks that an enum variant is in scope
let check_variant = |span, enum_id| {
let check_variant: @fn(span: span, enum_id: ast::def_id) =
|span, enum_id| {
let variant_info = ty::enum_variants(tcx, enum_id)[0];
let parental_privacy = if is_local(enum_id) {
let parent_vis = ast_map::node_item_query(tcx.items, enum_id.node,
Expand Down Expand Up @@ -81,7 +83,8 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
};

// Checks that a private field is in scope.
let check_field = |span, id, ident| {
let check_field: @fn(span: span, id: ast::def_id, ident: ast::ident) =
|span, id, ident| {
let fields = ty::lookup_struct_fields(tcx, id);
for fields.each |field| {
if field.ident != ident { loop; }
Expand All @@ -95,7 +98,8 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
};

// Checks that a private method is in scope.
let check_method = |span, origin: &method_origin| {
let check_method: @fn(span: span, origin: &method_origin) =
|span, origin| {
match *origin {
method_static(method_id) => {
if method_id.crate == local_crate {
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,8 +1608,9 @@ fn trans_match_inner(scope_cx: block,
if ty::type_is_empty(tcx, t) {
// Special case for empty types
let fail_cx = @mut None;
Some(|| mk_fail(scope_cx, discr_expr.span,
~"scrutinizing value that can't exist", fail_cx))
let f: mk_fail = || mk_fail(scope_cx, discr_expr.span,
~"scrutinizing value that can't exist", fail_cx);
Some(f)
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,7 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {

fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) -> encoder::encode_parms {
// XXX: Bad copy of `c`, whatever it is.
let encode_inlined_item =
let encode_inlined_item: encoder::encode_inlined_item =
|a,b,c,d| astencode::encode_inlined_item(a, b, copy c, d, cx.maps);

return {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/trans/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ fn trans_expr_fn(bcx: block,
~"expr_fn");
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);

// XXX: Bad copies.
let trans_closure_env = |proto, copy body, copy sub_path, copy decl| {
let trans_closure_env: &fn(ast::Proto) -> Result = |proto| {
let cap_vars = capture::compute_capture_vars(ccx.tcx, id, proto,
cap_clause);
let ret_handle = match is_loop_body { Some(x) => x, None => None };
// XXX: Bad copy.
let {llbox, cdata_ty, bcx} = build_closure(bcx, copy cap_vars, proto,
ret_handle);
trans_closure(ccx, /*bad*/copy sub_path, decl, body, llfn, no_self,
/*bad*/copy bcx.fcx.param_substs, id, None, |fcx| {
trans_closure(ccx, /*bad*/copy sub_path, decl, /*bad*/copy body, llfn,
no_self, /*bad*/copy bcx.fcx.param_substs, id, None,
|fcx| {
load_environment(fcx, cdata_ty, cap_vars,
ret_handle.is_some(), proto);
}, |bcx| {
Expand Down
10 changes: 8 additions & 2 deletions src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,14 @@ fn add_clean_temp_mem(bcx: block, val: ValueRef, t: ty::t) {
}
fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
let free_fn = match heap {
heap_shared => |a| glue::trans_free(a, ptr),
heap_exchange => |a| glue::trans_unique_free(a, ptr)
heap_shared => {
let f: @fn(block) -> block = |a| glue::trans_free(a, ptr);
f
}
heap_exchange => {
let f: @fn(block) -> block = |a| glue::trans_unique_free(a, ptr);
f
}
};
do in_scope_cx(cx) |scope_info| {
scope_info.cleanups.push(clean_temp(ptr, free_fn,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/monomorphize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
~[path_name((ccx.names)(ccx.sess.str_of(name)))]);
let s = mangle_exported_name(ccx, /*bad*/copy pt, mono_ty);

let mk_lldecl = |/*bad*/copy s| {
let mk_lldecl = || {
let lldecl = decl_internal_cdecl_fn(ccx.llmod, /*bad*/copy s, llfty);
ccx.monomorphized.insert(hash_id, lldecl);
lldecl
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
fn_ty.meta.onceness)
}
_ => {
(None, ast::impure_fn, ast::ProtoBox, ast::Many)
(None, ast::impure_fn, ast::ProtoBorrowed, ast::Many)
}
}
};
Expand Down
10 changes: 6 additions & 4 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
// of b -- skipping any inner loops (loop, while, loop_body)
fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
let rs = @mut false;
let visit_expr =
|e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| {
let visit_expr: @fn(@ast::expr,
&&flag: @mut bool,
v: visit::vt<@mut bool>) = |e, &&flag, v| {
*flag |= p(e.node);
match e.node {
// Skip inner loops, since a break in the inner loop isn't a
Expand All @@ -80,8 +81,9 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
// of b -- skipping any inner loops (loop, while, loop_body)
fn block_query(b: ast::blk, p: fn@(@ast::expr) -> bool) -> bool {
let rs = @mut false;
let visit_expr =
|e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| {
let visit_expr: @fn(@ast::expr,
&&flag: @mut bool,
v: visit::vt<@mut bool>) = |e, &&flag, v| {
*flag |= p(e);
visit::visit_expr(e, flag, v)
};
Expand Down
4 changes: 3 additions & 1 deletion src/libsyntax/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
fn collect(messages: @DVec<~str>)
-> fn@(Option<(@codemap::CodeMap, span)>, &str, level)
{
|_o, msg: &str, _l| { messages.push(msg.to_str()); }
let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) =
|_o, msg: &str, _l| { messages.push(msg.to_str()); };
f
}

fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/tt/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
cx.span_fatal(best_fail_spot, best_fail_msg);
}

let exp = |cx, sp, arg| generic_extension(cx, sp, name,
arg, lhses, rhses);
let exp: @fn(ext_ctxt, span, ~[ast::token_tree]) -> mac_result =
|cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses);

return mr_def({
name: *cx.parse_sess().interner.get(name),
Expand Down
3 changes: 2 additions & 1 deletion src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
f(fk, decl, body, sp, id);
visit_fn(fk, decl, body, sp, id, e, v);
}
let visit_ty = |a,b,c| v_ty(v.visit_ty, a, b, c);
let visit_ty: @fn(@Ty, &&x: (), vt<()>) =
|a,b,c| v_ty(v.visit_ty, a, b, c);
fn v_struct_field(f: fn@(@struct_field), sf: @struct_field, &&e: (),
v: vt<()>) {
f(sf);
Expand Down