From 9e610573ba285619c9a59d8c1468624b6428492c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Nov 2013 17:36:32 -0800 Subject: [PATCH] librustc: Remove remaining uses of `&fn()` in favor of `||`. --- doc/po/ja/rust.md.po | 2 +- doc/po/rust.md.pot | 2 +- doc/rust.md | 2 +- src/libextra/sort.rs | 2 +- src/librustc/front/config.rs | 2 +- src/librustc/metadata/decoder.rs | 14 +++---- src/librustc/metadata/encoder.rs | 8 ++-- src/librustc/metadata/filesearch.rs | 2 +- src/librustc/metadata/tydecode.rs | 2 +- src/librustc/middle/trans/_match.rs | 2 +- src/librustc/middle/trans/base.rs | 3 +- src/librustc/middle/trans/glue.rs | 3 +- src/librustc/middle/trans/tvec.rs | 3 +- src/librustc/middle/ty_fold.rs | 13 +++---- .../middle/typeck/check/regionmanip.rs | 2 +- src/librustc/middle/typeck/infer/lattice.rs | 4 +- src/librustc/util/common.rs | 4 +- src/librustdoc/html/format.rs | 4 +- src/librustdoc/html/render.rs | 6 +-- src/librustpkg/installed_packages.rs | 2 +- src/librustpkg/package_source.rs | 2 +- src/librustpkg/path_util.rs | 2 +- src/librustpkg/sha1.rs | 8 ++-- src/librustpkg/util.rs | 4 +- src/librustpkg/workspace.rs | 5 ++- src/libstd/cleanup.rs | 2 +- src/libstd/condition.rs | 4 +- src/libstd/iter.rs | 38 +++++++++---------- src/libstd/rand/distributions/mod.rs | 14 ++++--- src/libstd/str.rs | 2 +- src/libstd/to_bytes.rs | 2 +- src/libstd/unstable/finally.rs | 4 +- src/libstd/vec.rs | 20 +++++----- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/deriving/generic.rs | 11 +++--- src/libsyntax/ext/deriving/mod.rs | 22 +++++------ src/test/auxiliary/iss.rs | 2 +- src/test/bench/shootout-meteor.rs | 4 +- src/test/compile-fail/issue-4335.rs | 4 +- src/test/compile-fail/issue-4523.rs | 2 +- ...ased-on-type-no-recursive-stack-closure.rs | 2 +- src/test/compile-fail/regions-freevar.rs | 2 +- .../regions-infer-at-fn-not-param.rs | 6 +-- ...ns-infer-invariance-due-to-mutability-3.rs | 2 +- ...ns-infer-invariance-due-to-mutability-4.rs | 2 +- .../compile-fail/regions-infer-not-param.rs | 4 +- .../compile-fail/regions-steal-closure.rs | 4 +- src/test/run-fail/unwind-lambda.rs | 2 +- src/test/run-pass/const-fn-val.rs | 2 +- src/test/run-pass/const-vec-of-fns.rs | 2 +- src/test/run-pass/expr-block-fn.rs | 2 +- src/test/run-pass/expr-block-generic-box1.rs | 2 +- src/test/run-pass/expr-block-generic-box2.rs | 2 +- .../run-pass/expr-block-generic-unique1.rs | 2 +- .../run-pass/expr-block-generic-unique2.rs | 2 +- src/test/run-pass/expr-block-generic.rs | 2 +- src/test/run-pass/expr-if-generic-box1.rs | 2 +- src/test/run-pass/expr-if-generic-box2.rs | 2 +- src/test/run-pass/expr-if-generic.rs | 2 +- src/test/run-pass/expr-match-generic-box1.rs | 2 +- src/test/run-pass/expr-match-generic-box2.rs | 2 +- .../run-pass/expr-match-generic-unique1.rs | 2 +- .../run-pass/expr-match-generic-unique2.rs | 2 +- src/test/run-pass/fn-coerce-field.rs | 2 +- src/test/run-pass/hashmap-memory.rs | 2 +- src/test/run-pass/issue-1516.rs | 2 +- src/test/run-pass/issue-2185.rs | 2 +- src/test/run-pass/issue-3052.rs | 2 +- src/test/run-pass/last-use-in-cap-clause.rs | 4 +- src/test/run-pass/regions-copy-closure.rs | 4 +- src/test/run-pass/regions-dependent-autofn.rs | 4 +- src/test/run-pass/regions-static-closure.rs | 4 +- 72 files changed, 163 insertions(+), 153 deletions(-) diff --git a/doc/po/ja/rust.md.po b/doc/po/ja/rust.md.po index 24f07337df9..99392964e7a 100644 --- a/doc/po/ja/rust.md.po +++ b/doc/po/ja/rust.md.po @@ -5383,7 +5383,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2849 msgid "" -"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = " +"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = " "bo(5,7); ~~~~~~~~" msgstr "" diff --git a/doc/po/rust.md.pot b/doc/po/rust.md.pot index 80116dad4d3..1914526cb92 100644 --- a/doc/po/rust.md.pot +++ b/doc/po/rust.md.pot @@ -5370,7 +5370,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2849 msgid "" -"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = " +"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = " "bo(5,7); ~~~~~~~~" msgstr "" diff --git a/doc/rust.md b/doc/rust.md index fe8d0a834e3..bfc18a8473b 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3194,7 +3194,7 @@ fn add(x: int, y: int) -> int { let mut x = add(5,7); -type Binop<'self> = &'self fn(int,int) -> int; +type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = bo(5,7); ~~~~ diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index 60c4a75104b..175eaa2a8db 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -15,7 +15,7 @@ use std::cmp::{Eq, Ord}; use std::util::swap; use std::vec; -type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool; +type Le<'self, T> = 'self |v1: &T, v2: &T| -> bool; /** * Merge sort. Returns a new vector containing the sorted list. diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 296e8578cbe..460f1ff1262 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -13,7 +13,7 @@ use syntax::fold::ast_fold; use syntax::{ast, fold, attr}; struct Context<'self> { - in_cfg: &'self fn(attrs: &[ast::Attribute]) -> bool, + in_cfg: 'self |attrs: &[ast::Attribute]| -> bool, } // Support conditional compilation by transforming the AST, stripping out diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index fbe3d7bbe9e..dd70d29ec5b 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -74,7 +74,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: |&[u8]| -> bool, hash: u64) -> ret } -pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> Cmd; +pub type GetCrateDataCb<'self> = 'self |ast::CrateNum| -> Cmd; pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option { fn eq_item(bytes: &[u8], item_id: int) -> bool { @@ -528,7 +528,7 @@ struct EachItemContext<'self> { cdata: Cmd, get_crate_data: GetCrateDataCb<'self>, path_builder: &'self mut ~str, - callback: &'self fn(&str, DefLike, ast::visibility) -> bool, + callback: 'self |&str, DefLike, ast::visibility| -> bool, } impl<'self> EachItemContext<'self> { @@ -901,11 +901,11 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::path { item_path(lookup_item(id, cdata.data)) } -pub type decode_inlined_item<'self> = &'self fn( - cdata: @cstore::crate_metadata, - tcx: ty::ctxt, - path: ast_map::path, - par_doc: ebml::Doc) -> Option; +pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata, + tcx: ty::ctxt, + path: ast_map::path, + par_doc: ebml::Doc| + -> Option; pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, id: ast::NodeId, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 340a4241da2..c22f05d249c 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -52,10 +52,10 @@ use std::cast; // used by astencode: type abbrev_map = @mut HashMap; -pub type encode_inlined_item<'self> = &'self fn(ecx: &EncodeContext, - ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], - ii: ast::inlined_item); +pub type encode_inlined_item<'self> = 'self |ecx: &EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + ii: ast::inlined_item|; pub struct EncodeParams<'self> { diag: @mut span_handler, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index eccbe049e2b..4a27450bb43 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -23,7 +23,7 @@ pub enum FileMatch { FileMatches, FileDoesntMatch } /// Functions with type `pick` take a parent directory as well as /// a file found in that directory. -pub type pick<'self> = &'self fn(path: &Path) -> FileMatch; +pub type pick<'self> = 'self |path: &Path| -> FileMatch; pub fn pick_file(file: Path, path: &Path) -> Option { if path.filename() == Some(file.as_vec()) { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 281998b0811..27bca78b7b7 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -54,7 +54,7 @@ pub enum DefIdSource { RegionParameter, } type conv_did<'self> = - &'self fn(source: DefIdSource, ast::DefId) -> ast::DefId; + 'self |source: DefIdSource, ast::DefId| -> ast::DefId; pub struct PState<'self> { data: &'self [u8], diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 92913983d86..27d1e887bd3 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -477,7 +477,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) { } } -type enter_pat<'self> = &'self fn(@ast::Pat) -> Option<~[@ast::Pat]>; +type enter_pat<'self> = 'self |@ast::Pat| -> Option<~[@ast::Pat]>; fn enter_match<'r>(bcx: @mut Block, dm: DefMap, diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0ece7c8c024..ea9690ce406 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -669,7 +669,8 @@ pub fn compare_scalar_values(cx: @mut Block, } } -pub type val_and_ty_fn<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block; +pub type val_and_ty_fn<'self> = 'self |@mut Block, ValueRef, ty::t| + -> @mut Block; pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef { return Load(cx, GEPi(cx, p, idxs)); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 0993d3322f1..3eef1267429 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -642,7 +642,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info { return inf; } -pub type glue_helper<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block; +pub type glue_helper<'self> = 'self |@mut Block, ValueRef, ty::t| + -> @mut Block; pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type, name: &str) -> ValueRef { diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 93718fc1a23..82615b1e119 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -539,7 +539,8 @@ pub fn get_base_and_len(bcx: @mut Block, llval: ValueRef, vec_ty: ty::t) -> (Val } } -pub type iter_vec_block<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block; +pub type iter_vec_block<'self> = 'self |@mut Block, ValueRef, ty::t| + -> @mut Block; pub fn iter_vec_loop(bcx: @mut Block, data_ptr: ValueRef, diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index dc4fca0176a..2f35121dc02 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -224,7 +224,7 @@ pub fn super_fold_trait_store(this: &mut T, pub struct BottomUpFolder<'self> { tcx: ty::ctxt, - fldop: &'self fn(ty::t) -> ty::t, + fldop: 'self |ty::t| -> ty::t, } impl<'self> TypeFolder for BottomUpFolder<'self> { @@ -241,14 +241,14 @@ impl<'self> TypeFolder for BottomUpFolder<'self> { pub struct RegionFolder<'self> { tcx: ty::ctxt, - fld_t: &'self fn(ty::t) -> ty::t, - fld_r: &'self fn(ty::Region) -> ty::Region, + fld_t: 'self |ty::t| -> ty::t, + fld_r: 'self |ty::Region| -> ty::Region, } impl<'self> RegionFolder<'self> { pub fn general(tcx: ty::ctxt, - fld_r: &'self fn(ty::Region) -> ty::Region, - fld_t: &'self fn(ty::t) -> ty::t) + fld_r: 'self |ty::Region| -> ty::Region, + fld_t: 'self |ty::t| -> ty::t) -> RegionFolder<'self> { RegionFolder { tcx: tcx, @@ -257,8 +257,7 @@ impl<'self> RegionFolder<'self> { } } - pub fn regions(tcx: ty::ctxt, - fld_r: &'self fn(ty::Region) -> ty::Region) + pub fn regions(tcx: ty::ctxt, fld_r: 'self |ty::Region| -> ty::Region) -> RegionFolder<'self> { fn noop(t: ty::t) -> ty::t { t } diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index ebdd4b5f48c..7bf5eacb3d5 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -88,7 +88,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt, struct RegionRelator<'self> { tcx: ty::ctxt, stack: ~[ty::Region], - relate_op: &'self fn(ty::Region, ty::Region), + relate_op: 'self |ty::Region, ty::Region|, } // FIXME(#10151) -- Define more precisely when a region is diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 04bf5fda725..dbf11ab68bc 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -52,7 +52,7 @@ pub trait LatticeValue { } pub type LatticeOp<'self, T> = - &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres; + 'self |cf: &CombineFields, a: &T, b: &T| -> cres; impl LatticeValue for ty::t { fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { @@ -407,7 +407,7 @@ pub fn super_lattice_tys(this: &L, } } -pub type LatticeDirOp<'self, T> = &'self fn(a: &T, b: &T) -> cres; +pub type LatticeDirOp<'self, T> = 'self |a: &T, b: &T| -> cres; #[deriving(Clone)] pub enum LatticeVarResult { diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index ffbea94c477..28fe067293b 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -61,7 +61,7 @@ pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] { } struct LoopQueryVisitor<'self> { - p: &'self fn(&ast::Expr_) -> bool, + p: 'self |&ast::Expr_| -> bool, flag: bool, } @@ -89,7 +89,7 @@ pub fn loop_query(b: &ast::Block, p: |&ast::Expr_| -> bool) -> bool { } struct BlockQueryVisitor<'self> { - p: &'self fn(@ast::Expr) -> bool, + p: 'self |@ast::Expr| -> bool, flag: bool, } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ee2aaee240e..b191eb37af1 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -148,8 +148,8 @@ fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool, } fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool, - root: &fn(&render::Cache, &[~str]) -> Option<~str>, - info: &fn(&render::Cache) -> Option<(~[~str], &'static str)>) { + root: |&render::Cache, &[~str]| -> Option<~str>, + info: |&render::Cache| -> Option<(~[~str], &'static str)>) { // The generics will get written to both the title and link let mut generics = ~""; let last = path.segments.last(); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 96219479e10..9f0a4cefc4c 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -335,7 +335,7 @@ fn mkdir(path: &Path) { /// things like ".." to components which preserve the "top down" hierarchy of a /// static HTML tree. // FIXME (#9639): The closure should deal with &[u8] instead of &str -fn clean_srcpath(src: &[u8], f: &fn(&str)) { +fn clean_srcpath(src: &[u8], f: |&str|) { let p = Path::new(src); if p.as_vec() != bytes!(".") { for c in p.str_components().map(|x|x.unwrap()) { @@ -645,7 +645,7 @@ impl<'self> Cache { impl Context { /// Recurse in the directory structure and change the "root path" to make /// sure it always points to the top (relatively) - fn recurse(&mut self, s: ~str, f: &fn(&mut Context) -> T) -> T { + fn recurse(&mut self, s: ~str, f: |&mut Context| -> T) -> T { if s.len() == 0 { fail!("what {:?}", self); } @@ -768,7 +768,7 @@ impl Context { /// all sub-items which need to be rendered. /// /// The rendering driver uses this closure to queue up more work. - fn item(&mut self, item: clean::Item, f: &fn(&mut Context, clean::Item)) { + fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) { fn render(w: io::File, cx: &mut Context, it: &clean::Item, pushname: bool) { // A little unfortunate that this is done like this, but it sure diff --git a/src/librustpkg/installed_packages.rs b/src/librustpkg/installed_packages.rs index 855f6bbc3e5..3eed6314a03 100644 --- a/src/librustpkg/installed_packages.rs +++ b/src/librustpkg/installed_packages.rs @@ -16,7 +16,7 @@ use std::os; use std::io; use std::io::fs; -pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool { +pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool { let workspaces = rust_path(); for p in workspaces.iter() { let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) }; diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs index 7e1430792ff..4f48dab811f 100644 --- a/src/librustpkg/package_source.rs +++ b/src/librustpkg/package_source.rs @@ -348,7 +348,7 @@ impl PkgSrc { self.find_crates_with_filter(|_| true); } - pub fn find_crates_with_filter(&mut self, filter: &fn(&str) -> bool) { + pub fn find_crates_with_filter(&mut self, filter: |&str| -> bool) { use conditions::missing_pkg_files::cond; let prefix = self.start_dir.components().len(); diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index bce41e5a49f..adf86d2cf9d 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -63,7 +63,7 @@ pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool { pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path, // Returns the directory it was actually found in - workspace_to_src_dir: &fn(&Path) -> Path) -> Option { + workspace_to_src_dir: |&Path| -> Path) -> Option { if !workspace.is_dir() { return None; } diff --git a/src/librustpkg/sha1.rs b/src/librustpkg/sha1.rs index d955fd1aa97..db31f603d6e 100644 --- a/src/librustpkg/sha1.rs +++ b/src/librustpkg/sha1.rs @@ -94,7 +94,7 @@ fn add_bytes_to_bits(bits: T, bytes: T) -> T { trait FixedBuffer { /// Input a vector of bytes. If the buffer becomes full, process it with the provided /// function and then clear the buffer. - fn input(&mut self, input: &[u8], func: &fn(&[u8])); + fn input(&mut self, input: &[u8], func: |&[u8]|); /// Reset the buffer. fn reset(&mut self); @@ -137,7 +137,7 @@ impl FixedBuffer64 { } impl FixedBuffer for FixedBuffer64 { - fn input(&mut self, input: &[u8], func: &fn(&[u8])) { + fn input(&mut self, input: &[u8], func: |&[u8]|) { let mut i = 0; let size = 64; @@ -217,11 +217,11 @@ trait StandardPadding { /// and is guaranteed to have exactly rem remaining bytes when it returns. If there are not at /// least rem bytes available, the buffer will be zero padded, processed, cleared, and then /// filled with zeros again until only rem bytes are remaining. - fn standard_padding(&mut self, rem: uint, func: &fn(&[u8])); + fn standard_padding(&mut self, rem: uint, func: |&[u8]|); } impl StandardPadding for T { - fn standard_padding(&mut self, rem: uint, func: &fn(&[u8])) { + fn standard_padding(&mut self, rem: uint, func: |&[u8]|) { let size = self.size(); self.next(1)[0] = 128; diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 4f3d431543b..befb6aaa218 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -425,7 +425,7 @@ struct ViewItemVisitor<'self> { sess: session::Session, exec: &'self mut workcache::Exec, c: &'self ast::Crate, - save: &'self fn(Path), + save: 'self |Path|, deps: &'self mut DepMap } @@ -587,7 +587,7 @@ pub fn find_and_install_dependencies(context: &BuildContext, exec: &mut workcache::Exec, c: &ast::Crate, deps: &mut DepMap, - save: &fn(Path)) { + save: |Path|) { debug!("In find_and_install_dependencies..."); let mut visitor = ViewItemVisitor { context: context, diff --git a/src/librustpkg/workspace.rs b/src/librustpkg/workspace.rs index e65f3ce5bb6..22d673333e9 100644 --- a/src/librustpkg/workspace.rs +++ b/src/librustpkg/workspace.rs @@ -18,7 +18,10 @@ use path_util::rust_path; use util::option_to_vec; use package_id::PkgId; -pub fn each_pkg_parent_workspace(cx: &Context, pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool { +pub fn each_pkg_parent_workspace(cx: &Context, + pkgid: &PkgId, + action: |&Path| -> bool) + -> bool { // Using the RUST_PATH, find workspaces that contain // this package ID let workspaces = pkg_parent_workspaces(cx, pkgid); diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index a1f85097865..2f7b27b55e3 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -15,7 +15,7 @@ use ptr; use unstable::intrinsics::TyDesc; use unstable::raw; -type DropGlue<'self> = &'self fn(**TyDesc, *c_void); +type DropGlue<'self> = 'self |**TyDesc, *c_void|; /* * Box annihilation diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index 56d5a859401..03994043dcf 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -104,7 +104,7 @@ impl Condition { /// // use `trap`'s inside method to register the handler and then run a /// // block of code with the handler registered /// ``` - pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> { + pub fn trap<'a>(&'a self, h: 'a |T| -> U) -> Trap<'a, T, U> { let h: Closure = unsafe { ::cast::transmute(h) }; let prev = local_data::get(self.key, |k| k.map(|x| *x)); let h = @Handler { handle: h, prev: prev }; @@ -181,7 +181,7 @@ impl<'self, T, U> Trap<'self, T, U> { /// }; /// assert_eq!(result, 7); /// ``` - pub fn inside(&self, inner: &'self fn() -> V) -> V { + pub fn inside(&self, inner: 'self || -> V) -> V { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS"); local_data::set(self.cond.key, self.handler); diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index f736b10cc4f..b1958bde60d 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -156,7 +156,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn map<'r, B>(self, f: &'r fn(A) -> B) -> Map<'r, A, B, Self> { + fn map<'r, B>(self, f: 'r |A| -> B) -> Map<'r, A, B, Self> { Map{iter: self, f: f} } @@ -173,7 +173,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> Filter<'r, A, Self> { + fn filter<'r>(self, predicate: 'r |&A| -> bool) -> Filter<'r, A, Self> { Filter{iter: self, predicate: predicate} } @@ -190,7 +190,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn filter_map<'r, B>(self, f: &'r fn(A) -> Option) -> FilterMap<'r, A, B, Self> { + fn filter_map<'r, B>(self, f: 'r |A| -> Option) -> FilterMap<'r, A, B, Self> { FilterMap { iter: self, f: f } } @@ -249,7 +249,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhile<'r, A, Self> { + fn skip_while<'r>(self, predicate: 'r |&A| -> bool) -> SkipWhile<'r, A, Self> { SkipWhile{iter: self, flag: false, predicate: predicate} } @@ -267,7 +267,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhile<'r, A, Self> { + fn take_while<'r>(self, predicate: 'r |&A| -> bool) -> TakeWhile<'r, A, Self> { TakeWhile{iter: self, flag: false, predicate: predicate} } @@ -327,7 +327,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option) + fn scan<'r, St, B>(self, initial_state: St, f: 'r |&mut St, A| -> Option) -> Scan<'r, A, B, Self, St> { Scan{iter: self, f: f, state: initial_state} } @@ -349,7 +349,7 @@ pub trait Iterator { /// } /// ``` #[inline] - fn flat_map<'r, B, U: Iterator>(self, f: &'r fn(A) -> U) + fn flat_map<'r, B, U: Iterator>(self, f: 'r |A| -> U) -> FlatMap<'r, A, Self, U> { FlatMap{iter: self, f: f, frontiter: None, backiter: None } } @@ -401,7 +401,7 @@ pub trait Iterator { ///println(sum.to_str()); /// ``` #[inline] - fn inspect<'r>(self, f: &'r fn(&A)) -> Inspect<'r, A, Self> { + fn inspect<'r>(self, f: 'r |&A|) -> Inspect<'r, A, Self> { Inspect{iter: self, f: f} } @@ -1123,7 +1123,7 @@ RandomAccessIterator<(A, B)> for Zip { /// An iterator which maps the values of `iter` with `f` pub struct Map<'self, A, B, T> { priv iter: T, - priv f: &'self fn(A) -> B + priv f: 'self |A| -> B } impl<'self, A, B, T> Map<'self, A, B, T> { @@ -1172,7 +1172,7 @@ impl<'self, A, B, T: RandomAccessIterator> RandomAccessIterator for Map<'s /// An iterator which filters the elements of `iter` with `predicate` pub struct Filter<'self, A, T> { priv iter: T, - priv predicate: &'self fn(&A) -> bool + priv predicate: 'self |&A| -> bool } impl<'self, A, T: Iterator> Iterator for Filter<'self, A, T> { @@ -1216,7 +1216,7 @@ impl<'self, A, T: DoubleEndedIterator> DoubleEndedIterator for Filter<'sel /// An iterator which uses `f` to both filter and map elements from `iter` pub struct FilterMap<'self, A, B, T> { priv iter: T, - priv f: &'self fn(A) -> Option + priv f: 'self |A| -> Option } impl<'self, A, B, T: Iterator> Iterator for FilterMap<'self, A, B, T> { @@ -1359,7 +1359,7 @@ impl<'self, A, T: Iterator> Peekable { pub struct SkipWhile<'self, A, T> { priv iter: T, priv flag: bool, - priv predicate: &'self fn(&A) -> bool + priv predicate: 'self |&A| -> bool } impl<'self, A, T: Iterator> Iterator for SkipWhile<'self, A, T> { @@ -1397,7 +1397,7 @@ impl<'self, A, T: Iterator> Iterator for SkipWhile<'self, A, T> { pub struct TakeWhile<'self, A, T> { priv iter: T, priv flag: bool, - priv predicate: &'self fn(&A) -> bool + priv predicate: 'self |&A| -> bool } impl<'self, A, T: Iterator> Iterator for TakeWhile<'self, A, T> { @@ -1544,7 +1544,7 @@ impl> RandomAccessIterator for Take { /// An iterator to maintain state while iterating another iterator pub struct Scan<'self, A, B, T, St> { priv iter: T, - priv f: &'self fn(&mut St, A) -> Option, + priv f: 'self |&mut St, A| -> Option, /// The current internal state to be passed to the closure next. state: St @@ -1568,7 +1568,7 @@ impl<'self, A, B, T: Iterator, St> Iterator for Scan<'self, A, B, T, St> { /// pub struct FlatMap<'self, A, T, U> { priv iter: T, - priv f: &'self fn(A) -> U, + priv f: 'self |A| -> U, priv frontiter: Option, priv backiter: Option, } @@ -1699,7 +1699,7 @@ impl Fuse { /// element before yielding it. pub struct Inspect<'self, A, T> { priv iter: T, - priv f: &'self fn(&A) + priv f: 'self |&A| } impl<'self, A, T> Inspect<'self, A, T> { @@ -1751,7 +1751,7 @@ for Inspect<'self, A, T> { /// An iterator which just modifies the contained state throughout iteration. pub struct Unfold<'self, A, St> { - priv f: &'self fn(&mut St) -> Option, + priv f: 'self |&mut St| -> Option, /// Internal state that will be yielded on the next iteration state: St } @@ -1760,8 +1760,8 @@ impl<'self, A, St> Unfold<'self, A, St> { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the iterator #[inline] - pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option) - -> Unfold<'a, A, St> { + pub fn new<'a>(initial_state: St, f: 'a |&mut St| -> Option) + -> Unfold<'a, A, St> { Unfold { f: f, state: initial_state diff --git a/src/libstd/rand/distributions/mod.rs b/src/libstd/rand/distributions/mod.rs index dfdb08b7550..247a7824a44 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/libstd/rand/distributions/mod.rs @@ -205,12 +205,14 @@ mod ziggurat_tables; // the perf improvement (25-50%) is definitely worth the extra code // size from force-inlining. #[inline(always)] -fn ziggurat(rng: &mut R, - symmetric: bool, - X: ziggurat_tables::ZigTable, - F: ziggurat_tables::ZigTable, - pdf: &'static fn(f64) -> f64, - zero_case: &'static fn(&mut R, f64) -> f64) -> f64 { +fn ziggurat( + rng: &mut R, + symmetric: bool, + X: ziggurat_tables::ZigTable, + F: ziggurat_tables::ZigTable, + pdf: 'static |f64| -> f64, + zero_case: 'static |&mut R, f64| -> f64) + -> f64 { static SCALE: f64 = (1u64 << 53) as f64; loop { // reimplement the f64 generation as an optimisation suggested diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 3582782fc5e..11f552e73ae 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -322,7 +322,7 @@ impl CharEq for char { fn only_ascii(&self) -> bool { (*self as uint) < 128 } } -impl<'self> CharEq for &'self fn(char) -> bool { +impl<'self> CharEq for 'self |char| -> bool { #[inline] fn matches(&self, c: char) -> bool { (*self)(c) } diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 28b79bdd320..ded7cd8df07 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -22,7 +22,7 @@ use rc::Rc; use str::{Str, StrSlice}; use vec::{Vector, ImmutableVector}; -pub type Cb<'self> = &'self fn(buf: &[u8]) -> bool; +pub type Cb<'self> = 'self |buf: &[u8]| -> bool; /// /// A trait to implement in order to make a type hashable; diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index 58504832b2d..226ce9ef6f2 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -44,7 +44,7 @@ macro_rules! finally_fn { } } -impl<'self,T> Finally for &'self fn() -> T { +impl<'self,T> Finally for 'self || -> T { fn finally(&self, dtor: ||) -> T { let _d = Finallyalizer { dtor: dtor @@ -57,7 +57,7 @@ impl<'self,T> Finally for &'self fn() -> T { finally_fn!(extern "Rust" fn() -> T) struct Finallyalizer<'self> { - dtor: &'self fn() + dtor: 'self || } #[unsafe_destructor] diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 5fbf03c3cbb..0b08f9d00fa 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -222,7 +222,7 @@ pub fn build(size: Option, builder: |push: |v: A||) -> ~[A] { pub struct SplitIterator<'self, T> { priv v: &'self [T], priv n: uint, - priv pred: &'self fn(t: &T) -> bool, + priv pred: 'self |t: &T| -> bool, priv finished: bool } @@ -271,7 +271,7 @@ impl<'self, T> Iterator<&'self [T]> for SplitIterator<'self, T> { pub struct RSplitIterator<'self, T> { priv v: &'self [T], priv n: uint, - priv pred: &'self fn(t: &T) -> bool, + priv pred: 'self |t: &T| -> bool, priv finished: bool } @@ -859,20 +859,20 @@ pub trait ImmutableVector<'self, T> { fn rev_iter(self) -> RevIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`. - fn split(self, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T>; + fn split(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`, limited to splitting /// at most `n` times. - fn splitn(self, n: uint, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T>; + fn splitn(self, n: uint, pred: |&T| -> bool) -> SplitIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`. This starts at the /// end of the vector and works backwards. - fn rsplit(self, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T>; + fn rsplit(self, pred: |&T| -> bool) -> RSplitIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred` limited to splitting /// at most `n` times. This starts at the end of the vector and /// works backwards. - fn rsplitn(self, n: uint, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T>; + fn rsplitn(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>; /** * Returns an iterator over all contiguous windows of length @@ -1024,12 +1024,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn split(self, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T> { + fn split(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> { self.splitn(uint::max_value, pred) } #[inline] - fn splitn(self, n: uint, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T> { + fn splitn(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> { SplitIterator { v: self, n: n, @@ -1039,12 +1039,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn rsplit(self, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T> { + fn rsplit(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> { self.rsplitn(uint::max_value, pred) } #[inline] - fn rsplitn(self, n: uint, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T> { + fn rsplitn(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> { RSplitIterator { v: self, n: n, diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 16846823e0c..c14375604b1 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -669,7 +669,7 @@ pub trait EachViewItem { } struct EachViewItemData<'self> { - callback: &'self fn(&ast::view_item) -> bool, + callback: 'self |&ast::view_item| -> bool, } impl<'self> Visitor<()> for EachViewItemData<'self> { diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 23dc38fdc31..2f6cfeb24da 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -294,7 +294,7 @@ Combine the values of all the fields together. The last argument is all the fields of all the structures, see above for details. */ pub type CombineSubstructureFunc<'self> = - &'self fn(@ExtCtxt, Span, &Substructure) -> @Expr; + 'self |@ExtCtxt, Span, &Substructure| -> @Expr; /** Deal with non-matching enum variants, the arguments are a list @@ -302,10 +302,11 @@ representing each variant: (variant index, ast::variant instance, [variant fields]), and a list of the nonself args of the type */ pub type EnumNonMatchFunc<'self> = - &'self fn(@ExtCtxt, Span, - &[(uint, ast::variant, - ~[(Span, Option, @Expr)])], - &[@Expr]) -> @Expr; + 'self |@ExtCtxt, + Span, + &[(uint, ast::variant, ~[(Span, Option, @Expr)])], + &[@Expr]| + -> @Expr; impl<'self> TraitDef<'self> { diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 3e65f7bdefb..8729382141b 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -46,17 +46,17 @@ pub mod totalord; pub mod generic; -pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt, - Span, - x: &struct_def, - Ident, - y: &Generics) - -> @item; -pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt, - Span, - x: &enum_def, - Ident, - y: &Generics) +pub type ExpandDerivingStructDefFn<'self> = 'self |@ExtCtxt, + Span, + x: &struct_def, + Ident, + y: &Generics| + -> @item; +pub type ExpandDerivingEnumDefFn<'self> = 'self |@ExtCtxt, + Span, + x: &enum_def, + Ident, + y: &Generics| -> @item; pub fn expand_meta_deriving(cx: @ExtCtxt, diff --git a/src/test/auxiliary/iss.rs b/src/test/auxiliary/iss.rs index a3ead83321f..3855a348f60 100644 --- a/src/test/auxiliary/iss.rs +++ b/src/test/auxiliary/iss.rs @@ -13,7 +13,7 @@ // part of issue-6919.rs struct C<'self> { - k: &'self fn(), + k: 'self ||, } fn no_op() { } diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index e3fe631068c..7621d5d7b08 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -14,11 +14,11 @@ // returns an infinite iterator of repeated applications of f to x, // i.e. [x, f(x), f(f(x)), ...], as haskell iterate function. -fn iterate<'a, T>(x: T, f: &'a fn(&T) -> T) -> Iterate<'a, T> { +fn iterate<'a, T>(x: T, f: 'a |&T| -> T) -> Iterate<'a, T> { Iterate {f: f, next: x} } struct Iterate<'self, T> { - priv f: &'self fn(&T) -> T, + priv f: &'self |&T| -> T, priv next: T } impl<'self, T> Iterator for Iterate<'self, T> { diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 032b2564f4f..4cfa543a93f 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -10,7 +10,9 @@ fn id(t: T) -> T { t } -fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cannot infer an appropriate lifetime +fn f<'r, T>(v: &'r T) -> 'r || -> T { + id(|| *v) //~ ERROR cannot infer an appropriate lifetime +} fn main() { let v = &5; diff --git a/src/test/compile-fail/issue-4523.rs b/src/test/compile-fail/issue-4523.rs index 332db60c836..952a528b427 100644 --- a/src/test/compile-fail/issue-4523.rs +++ b/src/test/compile-fail/issue-4523.rs @@ -10,7 +10,7 @@ fn foopy() {} -static f: &'static fn() = foopy; //~ ERROR found extern fn +static f: 'static || = foopy; //~ ERROR found extern fn fn main () { f(); diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index db8effb1de3..bf7383f9c72 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -16,7 +16,7 @@ struct R<'self> { // This struct is needed to create the // otherwise infinite type of a fn that // accepts itself as argument: - c: &'self fn(&R, bool) + c: 'self |&R, bool| } fn innocent_looking_victim() { diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index 251be912359..7e5abe8e2f7 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn wants_static_fn(_x: &'static fn()) {} +fn wants_static_fn(_x: 'static ||) {} fn main() { let i = 3; diff --git a/src/test/compile-fail/regions-infer-at-fn-not-param.rs b/src/test/compile-fail/regions-infer-at-fn-not-param.rs index 3ddae976ce3..6347fa97c4d 100644 --- a/src/test/compile-fail/regions-infer-at-fn-not-param.rs +++ b/src/test/compile-fail/regions-infer-at-fn-not-param.rs @@ -9,15 +9,15 @@ // except according to those terms. struct parameterized1<'self> { - g: &'self fn() + g: 'self || } struct not_parameterized1 { - g: &'static fn() + g: 'static || } struct not_parameterized2 { - g: &'static fn() + g: 'static || } fn take1(p: parameterized1) -> parameterized1 { p } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs index 775164453e0..c7364a60bdf 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs @@ -11,7 +11,7 @@ #[feature(managed_boxes)]; struct invariant<'self> { - f: &'static fn(x: @mut &'self int) + f: 'static |x: @mut &'self int| } fn to_same_lifetime<'r>(bi: invariant<'r>) { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index 44856d9e531..8070d1f1dce 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -11,7 +11,7 @@ #[feature(managed_boxes)]; struct invariant<'self> { - f: &'static fn() -> @mut &'self int + f: 'static || -> @mut &'self int } fn to_same_lifetime<'r>(bi: invariant<'r>) { diff --git a/src/test/compile-fail/regions-infer-not-param.rs b/src/test/compile-fail/regions-infer-not-param.rs index 47c1f7a5757..92159489ae7 100644 --- a/src/test/compile-fail/regions-infer-not-param.rs +++ b/src/test/compile-fail/regions-infer-not-param.rs @@ -14,12 +14,12 @@ struct direct<'self> { struct indirect1 { // Here the lifetime parameter of direct is bound by the fn() - g: &'static fn(direct) + g: 'static |direct| } struct indirect2<'self> { // But here it is set to 'self - g: &'static fn(direct<'self>) + g: 'static |direct<'self>| } fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types diff --git a/src/test/compile-fail/regions-steal-closure.rs b/src/test/compile-fail/regions-steal-closure.rs index be034eda67d..292e282dd07 100644 --- a/src/test/compile-fail/regions-steal-closure.rs +++ b/src/test/compile-fail/regions-steal-closure.rs @@ -9,10 +9,10 @@ // except according to those terms. struct closure_box<'self> { - cl: &'self fn() + cl: 'self || } -fn box_it<'r>(x: &'r fn()) -> closure_box<'r> { +fn box_it<'r>(x: 'r ||) -> closure_box<'r> { closure_box {cl: x} } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index bd415e9eac3..ee570fa2e95 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -16,7 +16,7 @@ fn main() { let cheese = ~"roquefort"; let carrots = @~"crunchy"; - let result: &'static fn(@~str, |~str|) = (|tasties, macerate| { + let result: 'static |@~str, |~str|| = (|tasties, macerate| { macerate((*tasties).clone()); }); result(carrots, |food| { diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index dfcfb30f77f..126d53621dd 100644 --- a/src/test/run-pass/const-fn-val.rs +++ b/src/test/run-pass/const-fn-val.rs @@ -12,7 +12,7 @@ fn foo() -> int { return 0xca7f000d; } -struct Bar<'self> { f: &'self fn() -> int } +struct Bar<'self> { f: 'self || -> int } static b : Bar<'static> = Bar { f: foo }; diff --git a/src/test/run-pass/const-vec-of-fns.rs b/src/test/run-pass/const-vec-of-fns.rs index 6117ea962af..593d0e3125d 100644 --- a/src/test/run-pass/const-vec-of-fns.rs +++ b/src/test/run-pass/const-vec-of-fns.rs @@ -20,7 +20,7 @@ fn f() { } static bare_fns: &'static [extern fn()] = &[f, f]; -struct S<'self>(&'self fn()); +struct S<'self>('self ||); static closures: &'static [S<'static>] = &[S(f), S(f)]; pub fn main() { diff --git a/src/test/run-pass/expr-block-fn.rs b/src/test/run-pass/expr-block-fn.rs index 63e5c7688d3..e1850925223 100644 --- a/src/test/run-pass/expr-block-fn.rs +++ b/src/test/run-pass/expr-block-fn.rs @@ -11,7 +11,7 @@ fn test_fn() { - type t = &'static fn() -> int; + type t = 'static || -> int; fn ten() -> int { return 10; } let rs: t = { ten }; assert!((rs() == 10)); diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index 04c96bb2b98..f081d13a5b0 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -type compare = &'static fn(@T, @T) -> bool; +type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 562c3c1e523..04721c6bd94 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 159c2bfb8ef..f1df0e167b9 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -10,7 +10,7 @@ -type compare<'self, T> = &'self fn(~T, ~T) -> bool; +type compare<'self, T> = 'self |~T, ~T| -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { expected.clone() }; diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index ff811a9f458..b666a2f6760 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -10,7 +10,7 @@ // xfail-fast -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 800f22169d3..bc8c4c8983d 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -12,7 +12,7 @@ // xfail-fast // Tests for standalone blocks as expressions with dynamic type sizes -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index e6039d0601e..cba01fbd8dd 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -type compare = &'static fn(@T, @T) -> bool; +type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, not_expected: @T, eq: compare) { let actual: @T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index b8d872742ab..5ef97832221 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast -type compare = &'static fn(T, T) -> bool; +type compare = 'static |T, T| -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected.clone() } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 8e6e3f7ddda..bd1a550e205 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -11,7 +11,7 @@ // xfail-fast // Tests for if as expressions with dynamic type sizes -type compare = &'static fn(T, T) -> bool; +type compare = 'static |T, T| -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected.clone() } else { not_expected }; diff --git a/src/test/run-pass/expr-match-generic-box1.rs b/src/test/run-pass/expr-match-generic-box1.rs index 9220b0d697a..82e80e7da7d 100644 --- a/src/test/run-pass/expr-match-generic-box1.rs +++ b/src/test/run-pass/expr-match-generic-box1.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -type compare = &'static fn(@T, @T) -> bool; +type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = match true { true => { expected }, _ => fail!() }; diff --git a/src/test/run-pass/expr-match-generic-box2.rs b/src/test/run-pass/expr-match-generic-box2.rs index 430bd0f52c3..8fed749e302 100644 --- a/src/test/run-pass/expr-match-generic-box2.rs +++ b/src/test/run-pass/expr-match-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast -type compare = &'static fn(T, T) -> bool; +type compare = 'static |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; diff --git a/src/test/run-pass/expr-match-generic-unique1.rs b/src/test/run-pass/expr-match-generic-unique1.rs index b4bc7d3bef6..af9022ed322 100644 --- a/src/test/run-pass/expr-match-generic-unique1.rs +++ b/src/test/run-pass/expr-match-generic-unique1.rs @@ -10,7 +10,7 @@ -type compare = &'static fn(~T, ~T) -> bool; +type compare = 'static |~T, ~T| -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = match true { diff --git a/src/test/run-pass/expr-match-generic-unique2.rs b/src/test/run-pass/expr-match-generic-unique2.rs index 8eb5861f71e..2bd0f18ba0a 100644 --- a/src/test/run-pass/expr-match-generic-unique2.rs +++ b/src/test/run-pass/expr-match-generic-unique2.rs @@ -10,7 +10,7 @@ // xfail-fast -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { diff --git a/src/test/run-pass/fn-coerce-field.rs b/src/test/run-pass/fn-coerce-field.rs index ae2e353f913..809005258b5 100644 --- a/src/test/run-pass/fn-coerce-field.rs +++ b/src/test/run-pass/fn-coerce-field.rs @@ -9,7 +9,7 @@ // except according to those terms. struct r<'self> { - field: &'self fn() + field: 'self || } pub fn main() { diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 73595fd782c..1716f882dd8 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -24,7 +24,7 @@ mod map_reduce { use std::str; use std::task; - pub type putter<'self> = &'self fn(~str, ~str); + pub type putter<'self> = 'self |~str, ~str|; pub type mapper = extern fn(~str, putter); diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index 4b73d83595e..f3ffed7dc7b 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - let early_error: &'static fn(&str) -> ! = |_msg| { fail!() }; + let early_error: 'static |&str| -> ! = |_msg| { fail!() }; } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index afe7656b7a3..9ebeec092cf 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -18,7 +18,7 @@ // // Running /usr/local/bin/rustc: // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait -// issue-2185.rs:24 impl iterable for &'static fn(|uint|) { +// issue-2185.rs:24 impl iterable for 'static ||uint|| { // issue-2185.rs:25 fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) } // issue-2185.rs:26 } // issue-2185.rs:20:0: 22:1 note: note conflicting implementation here diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index cb1ffc38908..8179d85e601 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -type Connection = &'static fn(~[u8]); +type Connection = 'static |~[u8]|; fn f() -> Option { let mock_connection: Connection = |_| {}; diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index d014a3cf1a1..b72ef59075c 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -12,10 +12,10 @@ struct A { a: ~int } -fn foo() -> &'static fn() -> int { +fn foo() -> 'static || -> int { let k = ~22; let _u = A {a: k.clone()}; - let result: &'static fn() -> int = || 22; + let result: 'static || -> int = || 22; result } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 0b962731ecf..19fd1206419 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -9,10 +9,10 @@ // except according to those terms. struct closure_box<'self> { - cl: &'self fn(), + cl: 'self ||, } -fn box_it<'r>(x: &'r fn()) -> closure_box<'r> { +fn box_it<'r>(x: 'r ||) -> closure_box<'r> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions-dependent-autofn.rs b/src/test/run-pass/regions-dependent-autofn.rs index bce2159cc7b..b50930dd294 100644 --- a/src/test/run-pass/regions-dependent-autofn.rs +++ b/src/test/run-pass/regions-dependent-autofn.rs @@ -11,9 +11,9 @@ // Test lifetimes are linked properly when we autoslice a vector. // Issue #3148. -fn subslice<'r>(v: &'r fn()) -> &'r fn() { v } +fn subslice<'r>(v: 'r ||) -> 'r || { v } -fn both<'r>(v: &'r fn()) -> &'r fn() { +fn both<'r>(v: 'r ||) -> 'r || { subslice(subslice(v)) } diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index a2eb459ce20..941f2c5edfd 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -9,10 +9,10 @@ // except according to those terms. struct closure_box<'self> { - cl: &'self fn(), + cl: 'self ||, } -fn box_it<'r>(x: &'r fn()) -> closure_box<'r> { +fn box_it<'r>(x: 'r ||) -> closure_box<'r> { closure_box {cl: x} }