Skip to content

Commit 9e61057

Browse files
committed
librustc: Remove remaining uses of &fn() in favor of ||.
1 parent 4068139 commit 9e61057

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+163
-153
lines changed

doc/po/ja/rust.md.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5383,7 +5383,7 @@ msgstr ""
53835383
#. type: Plain text
53845384
#: doc/rust.md:2849
53855385
msgid ""
5386-
"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = "
5386+
"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = "
53875387
"bo(5,7); ~~~~~~~~"
53885388
msgstr ""
53895389

doc/po/rust.md.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5370,7 +5370,7 @@ msgstr ""
53705370
#. type: Plain text
53715371
#: doc/rust.md:2849
53725372
msgid ""
5373-
"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = "
5373+
"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = "
53745374
"bo(5,7); ~~~~~~~~"
53755375
msgstr ""
53765376

doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,7 @@ fn add(x: int, y: int) -> int {
31943194
31953195
let mut x = add(5,7);
31963196
3197-
type Binop<'self> = &'self fn(int,int) -> int;
3197+
type Binop<'self> = 'self |int,int| -> int;
31983198
let bo: Binop = add;
31993199
x = bo(5,7);
32003200
~~~~

src/libextra/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::cmp::{Eq, Ord};
1515
use std::util::swap;
1616
use std::vec;
1717

18-
type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
18+
type Le<'self, T> = 'self |v1: &T, v2: &T| -> bool;
1919

2020
/**
2121
* Merge sort. Returns a new vector containing the sorted list.

src/librustc/front/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use syntax::fold::ast_fold;
1313
use syntax::{ast, fold, attr};
1414

1515
struct Context<'self> {
16-
in_cfg: &'self fn(attrs: &[ast::Attribute]) -> bool,
16+
in_cfg: 'self |attrs: &[ast::Attribute]| -> bool,
1717
}
1818

1919
// Support conditional compilation by transforming the AST, stripping out

src/librustc/metadata/decoder.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: |&[u8]| -> bool, hash: u64) ->
7474
ret
7575
}
7676

77-
pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> Cmd;
77+
pub type GetCrateDataCb<'self> = 'self |ast::CrateNum| -> Cmd;
7878

7979
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
8080
fn eq_item(bytes: &[u8], item_id: int) -> bool {
@@ -528,7 +528,7 @@ struct EachItemContext<'self> {
528528
cdata: Cmd,
529529
get_crate_data: GetCrateDataCb<'self>,
530530
path_builder: &'self mut ~str,
531-
callback: &'self fn(&str, DefLike, ast::visibility) -> bool,
531+
callback: 'self |&str, DefLike, ast::visibility| -> bool,
532532
}
533533

534534
impl<'self> EachItemContext<'self> {
@@ -901,11 +901,11 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::path {
901901
item_path(lookup_item(id, cdata.data))
902902
}
903903

904-
pub type decode_inlined_item<'self> = &'self fn(
905-
cdata: @cstore::crate_metadata,
906-
tcx: ty::ctxt,
907-
path: ast_map::path,
908-
par_doc: ebml::Doc) -> Option<ast::inlined_item>;
904+
pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata,
905+
tcx: ty::ctxt,
906+
path: ast_map::path,
907+
par_doc: ebml::Doc|
908+
-> Option<ast::inlined_item>;
909909

910910
pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt,
911911
id: ast::NodeId,

src/librustc/metadata/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ use std::cast;
5252
// used by astencode:
5353
type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>;
5454

55-
pub type encode_inlined_item<'self> = &'self fn(ecx: &EncodeContext,
56-
ebml_w: &mut writer::Encoder,
57-
path: &[ast_map::path_elt],
58-
ii: ast::inlined_item);
55+
pub type encode_inlined_item<'self> = 'self |ecx: &EncodeContext,
56+
ebml_w: &mut writer::Encoder,
57+
path: &[ast_map::path_elt],
58+
ii: ast::inlined_item|;
5959

6060
pub struct EncodeParams<'self> {
6161
diag: @mut span_handler,

src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum FileMatch { FileMatches, FileDoesntMatch }
2323

2424
/// Functions with type `pick` take a parent directory as well as
2525
/// a file found in that directory.
26-
pub type pick<'self> = &'self fn(path: &Path) -> FileMatch;
26+
pub type pick<'self> = 'self |path: &Path| -> FileMatch;
2727

2828
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
2929
if path.filename() == Some(file.as_vec()) {

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub enum DefIdSource {
5454
RegionParameter,
5555
}
5656
type conv_did<'self> =
57-
&'self fn(source: DefIdSource, ast::DefId) -> ast::DefId;
57+
'self |source: DefIdSource, ast::DefId| -> ast::DefId;
5858

5959
pub struct PState<'self> {
6060
data: &'self [u8],

src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) {
477477
}
478478
}
479479

480-
type enter_pat<'self> = &'self fn(@ast::Pat) -> Option<~[@ast::Pat]>;
480+
type enter_pat<'self> = 'self |@ast::Pat| -> Option<~[@ast::Pat]>;
481481

482482
fn enter_match<'r>(bcx: @mut Block,
483483
dm: DefMap,

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,8 @@ pub fn compare_scalar_values(cx: @mut Block,
669669
}
670670
}
671671

672-
pub type val_and_ty_fn<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
672+
pub type val_and_ty_fn<'self> = 'self |@mut Block, ValueRef, ty::t|
673+
-> @mut Block;
673674

674675
pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
675676
return Load(cx, GEPi(cx, p, idxs));

src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
642642
return inf;
643643
}
644644

645-
pub type glue_helper<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
645+
pub type glue_helper<'self> = 'self |@mut Block, ValueRef, ty::t|
646+
-> @mut Block;
646647

647648
pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type,
648649
name: &str) -> ValueRef {

src/librustc/middle/trans/tvec.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ pub fn get_base_and_len(bcx: @mut Block, llval: ValueRef, vec_ty: ty::t) -> (Val
539539
}
540540
}
541541

542-
pub type iter_vec_block<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
542+
pub type iter_vec_block<'self> = 'self |@mut Block, ValueRef, ty::t|
543+
-> @mut Block;
543544

544545
pub fn iter_vec_loop(bcx: @mut Block,
545546
data_ptr: ValueRef,

src/librustc/middle/ty_fold.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub fn super_fold_trait_store<T:TypeFolder>(this: &mut T,
224224

225225
pub struct BottomUpFolder<'self> {
226226
tcx: ty::ctxt,
227-
fldop: &'self fn(ty::t) -> ty::t,
227+
fldop: 'self |ty::t| -> ty::t,
228228
}
229229

230230
impl<'self> TypeFolder for BottomUpFolder<'self> {
@@ -241,14 +241,14 @@ impl<'self> TypeFolder for BottomUpFolder<'self> {
241241

242242
pub struct RegionFolder<'self> {
243243
tcx: ty::ctxt,
244-
fld_t: &'self fn(ty::t) -> ty::t,
245-
fld_r: &'self fn(ty::Region) -> ty::Region,
244+
fld_t: 'self |ty::t| -> ty::t,
245+
fld_r: 'self |ty::Region| -> ty::Region,
246246
}
247247

248248
impl<'self> RegionFolder<'self> {
249249
pub fn general(tcx: ty::ctxt,
250-
fld_r: &'self fn(ty::Region) -> ty::Region,
251-
fld_t: &'self fn(ty::t) -> ty::t)
250+
fld_r: 'self |ty::Region| -> ty::Region,
251+
fld_t: 'self |ty::t| -> ty::t)
252252
-> RegionFolder<'self> {
253253
RegionFolder {
254254
tcx: tcx,
@@ -257,8 +257,7 @@ impl<'self> RegionFolder<'self> {
257257
}
258258
}
259259

260-
pub fn regions(tcx: ty::ctxt,
261-
fld_r: &'self fn(ty::Region) -> ty::Region)
260+
pub fn regions(tcx: ty::ctxt, fld_r: 'self |ty::Region| -> ty::Region)
262261
-> RegionFolder<'self> {
263262
fn noop(t: ty::t) -> ty::t { t }
264263

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
8888
struct RegionRelator<'self> {
8989
tcx: ty::ctxt,
9090
stack: ~[ty::Region],
91-
relate_op: &'self fn(ty::Region, ty::Region),
91+
relate_op: 'self |ty::Region, ty::Region|,
9292
}
9393

9494
// FIXME(#10151) -- Define more precisely when a region is

src/librustc/middle/typeck/infer/lattice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub trait LatticeValue {
5252
}
5353

5454
pub type LatticeOp<'self, T> =
55-
&'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
55+
'self |cf: &CombineFields, a: &T, b: &T| -> cres<T>;
5656

5757
impl LatticeValue for ty::t {
5858
fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
@@ -407,7 +407,7 @@ pub fn super_lattice_tys<L:LatticeDir+TyLatticeDir+Combine>(this: &L,
407407
}
408408
}
409409

410-
pub type LatticeDirOp<'self, T> = &'self fn(a: &T, b: &T) -> cres<T>;
410+
pub type LatticeDirOp<'self, T> = 'self |a: &T, b: &T| -> cres<T>;
411411

412412
#[deriving(Clone)]
413413
pub enum LatticeVarResult<V,T> {

src/librustc/util/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] {
6161
}
6262

6363
struct LoopQueryVisitor<'self> {
64-
p: &'self fn(&ast::Expr_) -> bool,
64+
p: 'self |&ast::Expr_| -> bool,
6565
flag: bool,
6666
}
6767

@@ -89,7 +89,7 @@ pub fn loop_query(b: &ast::Block, p: |&ast::Expr_| -> bool) -> bool {
8989
}
9090

9191
struct BlockQueryVisitor<'self> {
92-
p: &'self fn(@ast::Expr) -> bool,
92+
p: 'self |@ast::Expr| -> bool,
9393
flag: bool,
9494
}
9595

src/librustdoc/html/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool,
148148
}
149149

150150
fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
151-
root: &fn(&render::Cache, &[~str]) -> Option<~str>,
152-
info: &fn(&render::Cache) -> Option<(~[~str], &'static str)>) {
151+
root: |&render::Cache, &[~str]| -> Option<~str>,
152+
info: |&render::Cache| -> Option<(~[~str], &'static str)>) {
153153
// The generics will get written to both the title and link
154154
let mut generics = ~"";
155155
let last = path.segments.last();

src/librustdoc/html/render.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn mkdir(path: &Path) {
335335
/// things like ".." to components which preserve the "top down" hierarchy of a
336336
/// static HTML tree.
337337
// FIXME (#9639): The closure should deal with &[u8] instead of &str
338-
fn clean_srcpath(src: &[u8], f: &fn(&str)) {
338+
fn clean_srcpath(src: &[u8], f: |&str|) {
339339
let p = Path::new(src);
340340
if p.as_vec() != bytes!(".") {
341341
for c in p.str_components().map(|x|x.unwrap()) {
@@ -645,7 +645,7 @@ impl<'self> Cache {
645645
impl Context {
646646
/// Recurse in the directory structure and change the "root path" to make
647647
/// sure it always points to the top (relatively)
648-
fn recurse<T>(&mut self, s: ~str, f: &fn(&mut Context) -> T) -> T {
648+
fn recurse<T>(&mut self, s: ~str, f: |&mut Context| -> T) -> T {
649649
if s.len() == 0 {
650650
fail!("what {:?}", self);
651651
}
@@ -768,7 +768,7 @@ impl Context {
768768
/// all sub-items which need to be rendered.
769769
///
770770
/// The rendering driver uses this closure to queue up more work.
771-
fn item(&mut self, item: clean::Item, f: &fn(&mut Context, clean::Item)) {
771+
fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) {
772772
fn render(w: io::File, cx: &mut Context, it: &clean::Item,
773773
pushname: bool) {
774774
// A little unfortunate that this is done like this, but it sure

src/librustpkg/installed_packages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::os;
1616
use std::io;
1717
use std::io::fs;
1818

19-
pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool {
19+
pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool {
2020
let workspaces = rust_path();
2121
for p in workspaces.iter() {
2222
let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) };

src/librustpkg/package_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl PkgSrc {
348348
self.find_crates_with_filter(|_| true);
349349
}
350350

351-
pub fn find_crates_with_filter(&mut self, filter: &fn(&str) -> bool) {
351+
pub fn find_crates_with_filter(&mut self, filter: |&str| -> bool) {
352352
use conditions::missing_pkg_files::cond;
353353

354354
let prefix = self.start_dir.components().len();

src/librustpkg/path_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
6363

6464
pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
6565
// Returns the directory it was actually found in
66-
workspace_to_src_dir: &fn(&Path) -> Path) -> Option<Path> {
66+
workspace_to_src_dir: |&Path| -> Path) -> Option<Path> {
6767
if !workspace.is_dir() {
6868
return None;
6969
}

src/librustpkg/sha1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T {
9494
trait FixedBuffer {
9595
/// Input a vector of bytes. If the buffer becomes full, process it with the provided
9696
/// function and then clear the buffer.
97-
fn input(&mut self, input: &[u8], func: &fn(&[u8]));
97+
fn input(&mut self, input: &[u8], func: |&[u8]|);
9898

9999
/// Reset the buffer.
100100
fn reset(&mut self);
@@ -137,7 +137,7 @@ impl FixedBuffer64 {
137137
}
138138

139139
impl FixedBuffer for FixedBuffer64 {
140-
fn input(&mut self, input: &[u8], func: &fn(&[u8])) {
140+
fn input(&mut self, input: &[u8], func: |&[u8]|) {
141141
let mut i = 0;
142142

143143
let size = 64;
@@ -217,11 +217,11 @@ trait StandardPadding {
217217
/// and is guaranteed to have exactly rem remaining bytes when it returns. If there are not at
218218
/// least rem bytes available, the buffer will be zero padded, processed, cleared, and then
219219
/// filled with zeros again until only rem bytes are remaining.
220-
fn standard_padding(&mut self, rem: uint, func: &fn(&[u8]));
220+
fn standard_padding(&mut self, rem: uint, func: |&[u8]|);
221221
}
222222

223223
impl <T: FixedBuffer> StandardPadding for T {
224-
fn standard_padding(&mut self, rem: uint, func: &fn(&[u8])) {
224+
fn standard_padding(&mut self, rem: uint, func: |&[u8]|) {
225225
let size = self.size();
226226

227227
self.next(1)[0] = 128;

src/librustpkg/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ struct ViewItemVisitor<'self> {
425425
sess: session::Session,
426426
exec: &'self mut workcache::Exec,
427427
c: &'self ast::Crate,
428-
save: &'self fn(Path),
428+
save: 'self |Path|,
429429
deps: &'self mut DepMap
430430
}
431431

@@ -587,7 +587,7 @@ pub fn find_and_install_dependencies(context: &BuildContext,
587587
exec: &mut workcache::Exec,
588588
c: &ast::Crate,
589589
deps: &mut DepMap,
590-
save: &fn(Path)) {
590+
save: |Path|) {
591591
debug!("In find_and_install_dependencies...");
592592
let mut visitor = ViewItemVisitor {
593593
context: context,

src/librustpkg/workspace.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ use path_util::rust_path;
1818
use util::option_to_vec;
1919
use package_id::PkgId;
2020

21-
pub fn each_pkg_parent_workspace(cx: &Context, pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool {
21+
pub fn each_pkg_parent_workspace(cx: &Context,
22+
pkgid: &PkgId,
23+
action: |&Path| -> bool)
24+
-> bool {
2225
// Using the RUST_PATH, find workspaces that contain
2326
// this package ID
2427
let workspaces = pkg_parent_workspaces(cx, pkgid);

src/libstd/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ptr;
1515
use unstable::intrinsics::TyDesc;
1616
use unstable::raw;
1717

18-
type DropGlue<'self> = &'self fn(**TyDesc, *c_void);
18+
type DropGlue<'self> = 'self |**TyDesc, *c_void|;
1919

2020
/*
2121
* Box annihilation

src/libstd/condition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<T, U> Condition<T, U> {
104104
/// // use `trap`'s inside method to register the handler and then run a
105105
/// // block of code with the handler registered
106106
/// ```
107-
pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> {
107+
pub fn trap<'a>(&'a self, h: 'a |T| -> U) -> Trap<'a, T, U> {
108108
let h: Closure = unsafe { ::cast::transmute(h) };
109109
let prev = local_data::get(self.key, |k| k.map(|x| *x));
110110
let h = @Handler { handle: h, prev: prev };
@@ -181,7 +181,7 @@ impl<'self, T, U> Trap<'self, T, U> {
181181
/// };
182182
/// assert_eq!(result, 7);
183183
/// ```
184-
pub fn inside<V>(&self, inner: &'self fn() -> V) -> V {
184+
pub fn inside<V>(&self, inner: 'self || -> V) -> V {
185185
let _g = Guard { cond: self.cond };
186186
debug!("Trap: pushing handler to TLS");
187187
local_data::set(self.cond.key, self.handler);

0 commit comments

Comments
 (0)