librustc: Remove remaining uses of &fn() in favor of ||.

This commit is contained in:
Patrick Walton 2013-11-19 17:36:32 -08:00
parent 406813957b
commit 9e610573ba
72 changed files with 163 additions and 153 deletions

View file

@ -5383,7 +5383,7 @@ msgstr ""
#. type: Plain text #. type: Plain text
#: doc/rust.md:2849 #: doc/rust.md:2849
msgid "" 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); ~~~~~~~~" "bo(5,7); ~~~~~~~~"
msgstr "" msgstr ""

View file

@ -5370,7 +5370,7 @@ msgstr ""
#. type: Plain text #. type: Plain text
#: doc/rust.md:2849 #: doc/rust.md:2849
msgid "" 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); ~~~~~~~~" "bo(5,7); ~~~~~~~~"
msgstr "" msgstr ""

View file

@ -3194,7 +3194,7 @@ fn add(x: int, y: int) -> int {
let mut x = add(5,7); 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; let bo: Binop = add;
x = bo(5,7); x = bo(5,7);
~~~~ ~~~~

View file

@ -15,7 +15,7 @@ use std::cmp::{Eq, Ord};
use std::util::swap; use std::util::swap;
use std::vec; 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. * Merge sort. Returns a new vector containing the sorted list.

View file

@ -13,7 +13,7 @@ use syntax::fold::ast_fold;
use syntax::{ast, fold, attr}; use syntax::{ast, fold, attr};
struct Context<'self> { 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 // Support conditional compilation by transforming the AST, stripping out

View file

@ -74,7 +74,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: |&[u8]| -> bool, hash: u64) ->
ret 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<ebml::Doc> { pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
fn eq_item(bytes: &[u8], item_id: int) -> bool { fn eq_item(bytes: &[u8], item_id: int) -> bool {
@ -528,7 +528,7 @@ struct EachItemContext<'self> {
cdata: Cmd, cdata: Cmd,
get_crate_data: GetCrateDataCb<'self>, get_crate_data: GetCrateDataCb<'self>,
path_builder: &'self mut ~str, path_builder: &'self mut ~str,
callback: &'self fn(&str, DefLike, ast::visibility) -> bool, callback: 'self |&str, DefLike, ast::visibility| -> bool,
} }
impl<'self> EachItemContext<'self> { 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)) item_path(lookup_item(id, cdata.data))
} }
pub type decode_inlined_item<'self> = &'self fn( pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata,
cdata: @cstore::crate_metadata, tcx: ty::ctxt,
tcx: ty::ctxt, path: ast_map::path,
path: ast_map::path, par_doc: ebml::Doc|
par_doc: ebml::Doc) -> Option<ast::inlined_item>; -> Option<ast::inlined_item>;
pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt,
id: ast::NodeId, id: ast::NodeId,

View file

@ -52,10 +52,10 @@ use std::cast;
// used by astencode: // used by astencode:
type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>; type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>;
pub type encode_inlined_item<'self> = &'self fn(ecx: &EncodeContext, pub type encode_inlined_item<'self> = 'self |ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
path: &[ast_map::path_elt], path: &[ast_map::path_elt],
ii: ast::inlined_item); ii: ast::inlined_item|;
pub struct EncodeParams<'self> { pub struct EncodeParams<'self> {
diag: @mut span_handler, diag: @mut span_handler,

View file

@ -23,7 +23,7 @@ pub enum FileMatch { FileMatches, FileDoesntMatch }
/// Functions with type `pick` take a parent directory as well as /// Functions with type `pick` take a parent directory as well as
/// a file found in that directory. /// 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<Path> { pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
if path.filename() == Some(file.as_vec()) { if path.filename() == Some(file.as_vec()) {

View file

@ -54,7 +54,7 @@ pub enum DefIdSource {
RegionParameter, RegionParameter,
} }
type conv_did<'self> = type conv_did<'self> =
&'self fn(source: DefIdSource, ast::DefId) -> ast::DefId; 'self |source: DefIdSource, ast::DefId| -> ast::DefId;
pub struct PState<'self> { pub struct PState<'self> {
data: &'self [u8], data: &'self [u8],

View file

@ -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, fn enter_match<'r>(bcx: @mut Block,
dm: DefMap, dm: DefMap,

View file

@ -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 { pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
return Load(cx, GEPi(cx, p, idxs)); return Load(cx, GEPi(cx, p, idxs));

View file

@ -642,7 +642,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
return inf; 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, pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type,
name: &str) -> ValueRef { name: &str) -> ValueRef {

View file

@ -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, pub fn iter_vec_loop(bcx: @mut Block,
data_ptr: ValueRef, data_ptr: ValueRef,

View file

@ -224,7 +224,7 @@ pub fn super_fold_trait_store<T:TypeFolder>(this: &mut T,
pub struct BottomUpFolder<'self> { pub struct BottomUpFolder<'self> {
tcx: ty::ctxt, tcx: ty::ctxt,
fldop: &'self fn(ty::t) -> ty::t, fldop: 'self |ty::t| -> ty::t,
} }
impl<'self> TypeFolder for BottomUpFolder<'self> { impl<'self> TypeFolder for BottomUpFolder<'self> {
@ -241,14 +241,14 @@ impl<'self> TypeFolder for BottomUpFolder<'self> {
pub struct RegionFolder<'self> { pub struct RegionFolder<'self> {
tcx: ty::ctxt, tcx: ty::ctxt,
fld_t: &'self fn(ty::t) -> ty::t, fld_t: 'self |ty::t| -> ty::t,
fld_r: &'self fn(ty::Region) -> ty::Region, fld_r: 'self |ty::Region| -> ty::Region,
} }
impl<'self> RegionFolder<'self> { impl<'self> RegionFolder<'self> {
pub fn general(tcx: ty::ctxt, pub fn general(tcx: ty::ctxt,
fld_r: &'self fn(ty::Region) -> ty::Region, fld_r: 'self |ty::Region| -> ty::Region,
fld_t: &'self fn(ty::t) -> ty::t) fld_t: 'self |ty::t| -> ty::t)
-> RegionFolder<'self> { -> RegionFolder<'self> {
RegionFolder { RegionFolder {
tcx: tcx, tcx: tcx,
@ -257,8 +257,7 @@ impl<'self> RegionFolder<'self> {
} }
} }
pub fn regions(tcx: ty::ctxt, pub fn regions(tcx: ty::ctxt, fld_r: 'self |ty::Region| -> ty::Region)
fld_r: &'self fn(ty::Region) -> ty::Region)
-> RegionFolder<'self> { -> RegionFolder<'self> {
fn noop(t: ty::t) -> ty::t { t } fn noop(t: ty::t) -> ty::t { t }

View file

@ -88,7 +88,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
struct RegionRelator<'self> { struct RegionRelator<'self> {
tcx: ty::ctxt, tcx: ty::ctxt,
stack: ~[ty::Region], 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 // FIXME(#10151) -- Define more precisely when a region is

View file

@ -52,7 +52,7 @@ pub trait LatticeValue {
} }
pub type LatticeOp<'self, T> = pub type LatticeOp<'self, T> =
&'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>; 'self |cf: &CombineFields, a: &T, b: &T| -> cres<T>;
impl LatticeValue for ty::t { impl LatticeValue for ty::t {
fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { 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,
} }
} }
pub type LatticeDirOp<'self, T> = &'self fn(a: &T, b: &T) -> cres<T>; pub type LatticeDirOp<'self, T> = 'self |a: &T, b: &T| -> cres<T>;
#[deriving(Clone)] #[deriving(Clone)]
pub enum LatticeVarResult<V,T> { pub enum LatticeVarResult<V,T> {

View file

@ -61,7 +61,7 @@ pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] {
} }
struct LoopQueryVisitor<'self> { struct LoopQueryVisitor<'self> {
p: &'self fn(&ast::Expr_) -> bool, p: 'self |&ast::Expr_| -> bool,
flag: bool, flag: bool,
} }
@ -89,7 +89,7 @@ pub fn loop_query(b: &ast::Block, p: |&ast::Expr_| -> bool) -> bool {
} }
struct BlockQueryVisitor<'self> { struct BlockQueryVisitor<'self> {
p: &'self fn(@ast::Expr) -> bool, p: 'self |@ast::Expr| -> bool,
flag: bool, flag: bool,
} }

View file

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

View file

@ -335,7 +335,7 @@ fn mkdir(path: &Path) {
/// things like ".." to components which preserve the "top down" hierarchy of a /// things like ".." to components which preserve the "top down" hierarchy of a
/// static HTML tree. /// static HTML tree.
// FIXME (#9639): The closure should deal with &[u8] instead of &str // 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); let p = Path::new(src);
if p.as_vec() != bytes!(".") { if p.as_vec() != bytes!(".") {
for c in p.str_components().map(|x|x.unwrap()) { for c in p.str_components().map(|x|x.unwrap()) {
@ -645,7 +645,7 @@ impl<'self> Cache {
impl Context { impl Context {
/// Recurse in the directory structure and change the "root path" to make /// Recurse in the directory structure and change the "root path" to make
/// sure it always points to the top (relatively) /// sure it always points to the top (relatively)
fn recurse<T>(&mut self, s: ~str, f: &fn(&mut Context) -> T) -> T { fn recurse<T>(&mut self, s: ~str, f: |&mut Context| -> T) -> T {
if s.len() == 0 { if s.len() == 0 {
fail!("what {:?}", self); fail!("what {:?}", self);
} }
@ -768,7 +768,7 @@ impl Context {
/// all sub-items which need to be rendered. /// all sub-items which need to be rendered.
/// ///
/// The rendering driver uses this closure to queue up more work. /// 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, fn render(w: io::File, cx: &mut Context, it: &clean::Item,
pushname: bool) { pushname: bool) {
// A little unfortunate that this is done like this, but it sure // A little unfortunate that this is done like this, but it sure

View file

@ -16,7 +16,7 @@ use std::os;
use std::io; use std::io;
use std::io::fs; 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(); let workspaces = rust_path();
for p in workspaces.iter() { for p in workspaces.iter() {
let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) }; let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) };

View file

@ -348,7 +348,7 @@ impl PkgSrc {
self.find_crates_with_filter(|_| true); 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; use conditions::missing_pkg_files::cond;
let prefix = self.start_dir.components().len(); let prefix = self.start_dir.components().len();

View file

@ -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, pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
// Returns the directory it was actually found in // Returns the directory it was actually found in
workspace_to_src_dir: &fn(&Path) -> Path) -> Option<Path> { workspace_to_src_dir: |&Path| -> Path) -> Option<Path> {
if !workspace.is_dir() { if !workspace.is_dir() {
return None; return None;
} }

View file

@ -94,7 +94,7 @@ fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T {
trait FixedBuffer { trait FixedBuffer {
/// Input a vector of bytes. If the buffer becomes full, process it with the provided /// Input a vector of bytes. If the buffer becomes full, process it with the provided
/// function and then clear the buffer. /// 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. /// Reset the buffer.
fn reset(&mut self); fn reset(&mut self);
@ -137,7 +137,7 @@ impl FixedBuffer64 {
} }
impl FixedBuffer for 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 mut i = 0;
let size = 64; 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 /// 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 /// least rem bytes available, the buffer will be zero padded, processed, cleared, and then
/// filled with zeros again until only rem bytes are remaining. /// 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 <T: FixedBuffer> StandardPadding for T { impl <T: FixedBuffer> 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(); let size = self.size();
self.next(1)[0] = 128; self.next(1)[0] = 128;

View file

@ -425,7 +425,7 @@ struct ViewItemVisitor<'self> {
sess: session::Session, sess: session::Session,
exec: &'self mut workcache::Exec, exec: &'self mut workcache::Exec,
c: &'self ast::Crate, c: &'self ast::Crate,
save: &'self fn(Path), save: 'self |Path|,
deps: &'self mut DepMap deps: &'self mut DepMap
} }
@ -587,7 +587,7 @@ pub fn find_and_install_dependencies(context: &BuildContext,
exec: &mut workcache::Exec, exec: &mut workcache::Exec,
c: &ast::Crate, c: &ast::Crate,
deps: &mut DepMap, deps: &mut DepMap,
save: &fn(Path)) { save: |Path|) {
debug!("In find_and_install_dependencies..."); debug!("In find_and_install_dependencies...");
let mut visitor = ViewItemVisitor { let mut visitor = ViewItemVisitor {
context: context, context: context,

View file

@ -18,7 +18,10 @@ use path_util::rust_path;
use util::option_to_vec; use util::option_to_vec;
use package_id::PkgId; 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 // Using the RUST_PATH, find workspaces that contain
// this package ID // this package ID
let workspaces = pkg_parent_workspaces(cx, pkgid); let workspaces = pkg_parent_workspaces(cx, pkgid);

View file

@ -15,7 +15,7 @@ use ptr;
use unstable::intrinsics::TyDesc; use unstable::intrinsics::TyDesc;
use unstable::raw; use unstable::raw;
type DropGlue<'self> = &'self fn(**TyDesc, *c_void); type DropGlue<'self> = 'self |**TyDesc, *c_void|;
/* /*
* Box annihilation * Box annihilation

View file

@ -104,7 +104,7 @@ impl<T, U> Condition<T, U> {
/// // use `trap`'s inside method to register the handler and then run a /// // use `trap`'s inside method to register the handler and then run a
/// // block of code with the handler registered /// // 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 h: Closure = unsafe { ::cast::transmute(h) };
let prev = local_data::get(self.key, |k| k.map(|x| *x)); let prev = local_data::get(self.key, |k| k.map(|x| *x));
let h = @Handler { handle: h, prev: prev }; let h = @Handler { handle: h, prev: prev };
@ -181,7 +181,7 @@ impl<'self, T, U> Trap<'self, T, U> {
/// }; /// };
/// assert_eq!(result, 7); /// assert_eq!(result, 7);
/// ``` /// ```
pub fn inside<V>(&self, inner: &'self fn() -> V) -> V { pub fn inside<V>(&self, inner: 'self || -> V) -> V {
let _g = Guard { cond: self.cond }; let _g = Guard { cond: self.cond };
debug!("Trap: pushing handler to TLS"); debug!("Trap: pushing handler to TLS");
local_data::set(self.cond.key, self.handler); local_data::set(self.cond.key, self.handler);

View file

@ -156,7 +156,7 @@ pub trait Iterator<A> {
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ``` /// ```
#[inline] #[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} Map{iter: self, f: f}
} }
@ -173,7 +173,7 @@ pub trait Iterator<A> {
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ``` /// ```
#[inline] #[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} Filter{iter: self, predicate: predicate}
} }
@ -190,7 +190,7 @@ pub trait Iterator<A> {
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ``` /// ```
#[inline] #[inline]
fn filter_map<'r, B>(self, f: &'r fn(A) -> Option<B>) -> FilterMap<'r, A, B, Self> { fn filter_map<'r, B>(self, f: 'r |A| -> Option<B>) -> FilterMap<'r, A, B, Self> {
FilterMap { iter: self, f: f } FilterMap { iter: self, f: f }
} }
@ -249,7 +249,7 @@ pub trait Iterator<A> {
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ``` /// ```
#[inline] #[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} SkipWhile{iter: self, flag: false, predicate: predicate}
} }
@ -267,7 +267,7 @@ pub trait Iterator<A> {
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ``` /// ```
#[inline] #[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} TakeWhile{iter: self, flag: false, predicate: predicate}
} }
@ -327,7 +327,7 @@ pub trait Iterator<A> {
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ``` /// ```
#[inline] #[inline]
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>) fn scan<'r, St, B>(self, initial_state: St, f: 'r |&mut St, A| -> Option<B>)
-> Scan<'r, A, B, Self, St> { -> Scan<'r, A, B, Self, St> {
Scan{iter: self, f: f, state: initial_state} Scan{iter: self, f: f, state: initial_state}
} }
@ -349,7 +349,7 @@ pub trait Iterator<A> {
/// } /// }
/// ``` /// ```
#[inline] #[inline]
fn flat_map<'r, B, U: Iterator<B>>(self, f: &'r fn(A) -> U) fn flat_map<'r, B, U: Iterator<B>>(self, f: 'r |A| -> U)
-> FlatMap<'r, A, Self, U> { -> FlatMap<'r, A, Self, U> {
FlatMap{iter: self, f: f, frontiter: None, backiter: None } FlatMap{iter: self, f: f, frontiter: None, backiter: None }
} }
@ -401,7 +401,7 @@ pub trait Iterator<A> {
///println(sum.to_str()); ///println(sum.to_str());
/// ``` /// ```
#[inline] #[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} Inspect{iter: self, f: f}
} }
@ -1123,7 +1123,7 @@ RandomAccessIterator<(A, B)> for Zip<T, U> {
/// An iterator which maps the values of `iter` with `f` /// An iterator which maps the values of `iter` with `f`
pub struct Map<'self, A, B, T> { pub struct Map<'self, A, B, T> {
priv iter: 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> { impl<'self, A, B, T> Map<'self, A, B, T> {
@ -1172,7 +1172,7 @@ impl<'self, A, B, T: RandomAccessIterator<A>> RandomAccessIterator<B> for Map<'s
/// An iterator which filters the elements of `iter` with `predicate` /// An iterator which filters the elements of `iter` with `predicate`
pub struct Filter<'self, A, T> { pub struct Filter<'self, A, T> {
priv iter: T, priv iter: T,
priv predicate: &'self fn(&A) -> bool priv predicate: 'self |&A| -> bool
} }
impl<'self, A, T: Iterator<A>> Iterator<A> for Filter<'self, A, T> { impl<'self, A, T: Iterator<A>> Iterator<A> for Filter<'self, A, T> {
@ -1216,7 +1216,7 @@ impl<'self, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for Filter<'sel
/// An iterator which uses `f` to both filter and map elements from `iter` /// An iterator which uses `f` to both filter and map elements from `iter`
pub struct FilterMap<'self, A, B, T> { pub struct FilterMap<'self, A, B, T> {
priv iter: T, priv iter: T,
priv f: &'self fn(A) -> Option<B> priv f: 'self |A| -> Option<B>
} }
impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMap<'self, A, B, T> { impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMap<'self, A, B, T> {
@ -1359,7 +1359,7 @@ impl<'self, A, T: Iterator<A>> Peekable<A, T> {
pub struct SkipWhile<'self, A, T> { pub struct SkipWhile<'self, A, T> {
priv iter: T, priv iter: T,
priv flag: bool, priv flag: bool,
priv predicate: &'self fn(&A) -> bool priv predicate: 'self |&A| -> bool
} }
impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhile<'self, A, T> { impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhile<'self, A, T> {
@ -1397,7 +1397,7 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhile<'self, A, T> {
pub struct TakeWhile<'self, A, T> { pub struct TakeWhile<'self, A, T> {
priv iter: T, priv iter: T,
priv flag: bool, priv flag: bool,
priv predicate: &'self fn(&A) -> bool priv predicate: 'self |&A| -> bool
} }
impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhile<'self, A, T> { impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhile<'self, A, T> {
@ -1544,7 +1544,7 @@ impl<A, T: RandomAccessIterator<A>> RandomAccessIterator<A> for Take<T> {
/// An iterator to maintain state while iterating another iterator /// An iterator to maintain state while iterating another iterator
pub struct Scan<'self, A, B, T, St> { pub struct Scan<'self, A, B, T, St> {
priv iter: T, priv iter: T,
priv f: &'self fn(&mut St, A) -> Option<B>, priv f: 'self |&mut St, A| -> Option<B>,
/// The current internal state to be passed to the closure next. /// The current internal state to be passed to the closure next.
state: St state: St
@ -1568,7 +1568,7 @@ impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for Scan<'self, A, B, T, St> {
/// ///
pub struct FlatMap<'self, A, T, U> { pub struct FlatMap<'self, A, T, U> {
priv iter: T, priv iter: T,
priv f: &'self fn(A) -> U, priv f: 'self |A| -> U,
priv frontiter: Option<U>, priv frontiter: Option<U>,
priv backiter: Option<U>, priv backiter: Option<U>,
} }
@ -1699,7 +1699,7 @@ impl<T> Fuse<T> {
/// element before yielding it. /// element before yielding it.
pub struct Inspect<'self, A, T> { pub struct Inspect<'self, A, T> {
priv iter: T, priv iter: T,
priv f: &'self fn(&A) priv f: 'self |&A|
} }
impl<'self, A, T> Inspect<'self, A, T> { 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. /// An iterator which just modifies the contained state throughout iteration.
pub struct Unfold<'self, A, St> { pub struct Unfold<'self, A, St> {
priv f: &'self fn(&mut St) -> Option<A>, priv f: 'self |&mut St| -> Option<A>,
/// Internal state that will be yielded on the next iteration /// Internal state that will be yielded on the next iteration
state: St 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 /// Creates a new iterator with the specified closure as the "iterator
/// function" and an initial state to eventually pass to the iterator /// function" and an initial state to eventually pass to the iterator
#[inline] #[inline]
pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>) pub fn new<'a>(initial_state: St, f: 'a |&mut St| -> Option<A>)
-> Unfold<'a, A, St> { -> Unfold<'a, A, St> {
Unfold { Unfold {
f: f, f: f,
state: initial_state state: initial_state

View file

@ -205,12 +205,14 @@ mod ziggurat_tables;
// the perf improvement (25-50%) is definitely worth the extra code // the perf improvement (25-50%) is definitely worth the extra code
// size from force-inlining. // size from force-inlining.
#[inline(always)] #[inline(always)]
fn ziggurat<R:Rng>(rng: &mut R, fn ziggurat<R:Rng>(
symmetric: bool, rng: &mut R,
X: ziggurat_tables::ZigTable, symmetric: bool,
F: ziggurat_tables::ZigTable, X: ziggurat_tables::ZigTable,
pdf: &'static fn(f64) -> f64, F: ziggurat_tables::ZigTable,
zero_case: &'static fn(&mut R, f64) -> f64) -> f64 { pdf: 'static |f64| -> f64,
zero_case: 'static |&mut R, f64| -> f64)
-> f64 {
static SCALE: f64 = (1u64 << 53) as f64; static SCALE: f64 = (1u64 << 53) as f64;
loop { loop {
// reimplement the f64 generation as an optimisation suggested // reimplement the f64 generation as an optimisation suggested

View file

@ -322,7 +322,7 @@ impl CharEq for char {
fn only_ascii(&self) -> bool { (*self as uint) < 128 } 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] #[inline]
fn matches(&self, c: char) -> bool { (*self)(c) } fn matches(&self, c: char) -> bool { (*self)(c) }

View file

@ -22,7 +22,7 @@ use rc::Rc;
use str::{Str, StrSlice}; use str::{Str, StrSlice};
use vec::{Vector, ImmutableVector}; 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; /// A trait to implement in order to make a type hashable;

View file

@ -44,7 +44,7 @@ macro_rules! finally_fn {
} }
} }
impl<'self,T> Finally<T> for &'self fn() -> T { impl<'self,T> Finally<T> for 'self || -> T {
fn finally(&self, dtor: ||) -> T { fn finally(&self, dtor: ||) -> T {
let _d = Finallyalizer { let _d = Finallyalizer {
dtor: dtor dtor: dtor
@ -57,7 +57,7 @@ impl<'self,T> Finally<T> for &'self fn() -> T {
finally_fn!(extern "Rust" fn() -> T) finally_fn!(extern "Rust" fn() -> T)
struct Finallyalizer<'self> { struct Finallyalizer<'self> {
dtor: &'self fn() dtor: 'self ||
} }
#[unsafe_destructor] #[unsafe_destructor]

View file

@ -222,7 +222,7 @@ pub fn build<A>(size: Option<uint>, builder: |push: |v: A||) -> ~[A] {
pub struct SplitIterator<'self, T> { pub struct SplitIterator<'self, T> {
priv v: &'self [T], priv v: &'self [T],
priv n: uint, priv n: uint,
priv pred: &'self fn(t: &T) -> bool, priv pred: 'self |t: &T| -> bool,
priv finished: bool priv finished: bool
} }
@ -271,7 +271,7 @@ impl<'self, T> Iterator<&'self [T]> for SplitIterator<'self, T> {
pub struct RSplitIterator<'self, T> { pub struct RSplitIterator<'self, T> {
priv v: &'self [T], priv v: &'self [T],
priv n: uint, priv n: uint,
priv pred: &'self fn(t: &T) -> bool, priv pred: 'self |t: &T| -> bool,
priv finished: bool priv finished: bool
} }
@ -859,20 +859,20 @@ pub trait ImmutableVector<'self, T> {
fn rev_iter(self) -> RevIterator<'self, T>; fn rev_iter(self) -> RevIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are /// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`. /// 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 /// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`, limited to splitting /// separated by elements that match `pred`, limited to splitting
/// at most `n` times. /// 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 /// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`. This starts at the /// separated by elements that match `pred`. This starts at the
/// end of the vector and works backwards. /// 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 /// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred` limited to splitting /// separated by elements that match `pred` limited to splitting
/// at most `n` times. This starts at the end of the vector and /// at most `n` times. This starts at the end of the vector and
/// works backwards. /// 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 * Returns an iterator over all contiguous windows of length
@ -1024,12 +1024,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
} }
#[inline] #[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) self.splitn(uint::max_value, pred)
} }
#[inline] #[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 { SplitIterator {
v: self, v: self,
n: n, n: n,
@ -1039,12 +1039,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
} }
#[inline] #[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) self.rsplitn(uint::max_value, pred)
} }
#[inline] #[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 { RSplitIterator {
v: self, v: self,
n: n, n: n,

View file

@ -669,7 +669,7 @@ pub trait EachViewItem {
} }
struct EachViewItemData<'self> { struct EachViewItemData<'self> {
callback: &'self fn(&ast::view_item) -> bool, callback: 'self |&ast::view_item| -> bool,
} }
impl<'self> Visitor<()> for EachViewItemData<'self> { impl<'self> Visitor<()> for EachViewItemData<'self> {

View file

@ -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. all the fields of all the structures, see above for details.
*/ */
pub type CombineSubstructureFunc<'self> = 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 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 [variant fields]), and a list of the nonself args of the type
*/ */
pub type EnumNonMatchFunc<'self> = pub type EnumNonMatchFunc<'self> =
&'self fn(@ExtCtxt, Span, 'self |@ExtCtxt,
&[(uint, ast::variant, Span,
~[(Span, Option<Ident>, @Expr)])], &[(uint, ast::variant, ~[(Span, Option<Ident>, @Expr)])],
&[@Expr]) -> @Expr; &[@Expr]|
-> @Expr;
impl<'self> TraitDef<'self> { impl<'self> TraitDef<'self> {

View file

@ -46,17 +46,17 @@ pub mod totalord;
pub mod generic; pub mod generic;
pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt, pub type ExpandDerivingStructDefFn<'self> = 'self |@ExtCtxt,
Span, Span,
x: &struct_def, x: &struct_def,
Ident, Ident,
y: &Generics) y: &Generics|
-> @item; -> @item;
pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt, pub type ExpandDerivingEnumDefFn<'self> = 'self |@ExtCtxt,
Span, Span,
x: &enum_def, x: &enum_def,
Ident, Ident,
y: &Generics) y: &Generics|
-> @item; -> @item;
pub fn expand_meta_deriving(cx: @ExtCtxt, pub fn expand_meta_deriving(cx: @ExtCtxt,

View file

@ -13,7 +13,7 @@
// part of issue-6919.rs // part of issue-6919.rs
struct C<'self> { struct C<'self> {
k: &'self fn(), k: 'self ||,
} }
fn no_op() { } fn no_op() { }

View file

@ -14,11 +14,11 @@
// returns an infinite iterator of repeated applications of f to x, // returns an infinite iterator of repeated applications of f to x,
// i.e. [x, f(x), f(f(x)), ...], as haskell iterate function. // 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} Iterate {f: f, next: x}
} }
struct Iterate<'self, T> { struct Iterate<'self, T> {
priv f: &'self fn(&T) -> T, priv f: &'self |&T| -> T,
priv next: T priv next: T
} }
impl<'self, T> Iterator<T> for Iterate<'self, T> { impl<'self, T> Iterator<T> for Iterate<'self, T> {

View file

@ -10,7 +10,9 @@
fn id<T>(t: T) -> T { t } fn id<T>(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() { fn main() {
let v = &5; let v = &5;

View file

@ -10,7 +10,7 @@
fn foopy() {} fn foopy() {}
static f: &'static fn() = foopy; //~ ERROR found extern fn static f: 'static || = foopy; //~ ERROR found extern fn
fn main () { fn main () {
f(); f();

View file

@ -16,7 +16,7 @@ struct R<'self> {
// This struct is needed to create the // This struct is needed to create the
// otherwise infinite type of a fn that // otherwise infinite type of a fn that
// accepts itself as argument: // accepts itself as argument:
c: &'self fn(&R, bool) c: 'self |&R, bool|
} }
fn innocent_looking_victim() { fn innocent_looking_victim() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
fn wants_static_fn(_x: &'static fn()) {} fn wants_static_fn(_x: 'static ||) {}
fn main() { fn main() {
let i = 3; let i = 3;

View file

@ -9,15 +9,15 @@
// except according to those terms. // except according to those terms.
struct parameterized1<'self> { struct parameterized1<'self> {
g: &'self fn() g: 'self ||
} }
struct not_parameterized1 { struct not_parameterized1 {
g: &'static fn() g: 'static ||
} }
struct not_parameterized2 { struct not_parameterized2 {
g: &'static fn() g: 'static ||
} }
fn take1(p: parameterized1) -> parameterized1 { p } fn take1(p: parameterized1) -> parameterized1 { p }

View file

@ -11,7 +11,7 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
struct invariant<'self> { struct invariant<'self> {
f: &'static fn(x: @mut &'self int) f: 'static |x: @mut &'self int|
} }
fn to_same_lifetime<'r>(bi: invariant<'r>) { fn to_same_lifetime<'r>(bi: invariant<'r>) {

View file

@ -11,7 +11,7 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
struct invariant<'self> { struct invariant<'self> {
f: &'static fn() -> @mut &'self int f: 'static || -> @mut &'self int
} }
fn to_same_lifetime<'r>(bi: invariant<'r>) { fn to_same_lifetime<'r>(bi: invariant<'r>) {

View file

@ -14,12 +14,12 @@ struct direct<'self> {
struct indirect1 { struct indirect1 {
// Here the lifetime parameter of direct is bound by the fn() // Here the lifetime parameter of direct is bound by the fn()
g: &'static fn(direct) g: 'static |direct|
} }
struct indirect2<'self> { struct indirect2<'self> {
// But here it is set to '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 fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types

View file

@ -9,10 +9,10 @@
// except according to those terms. // except according to those terms.
struct closure_box<'self> { 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} closure_box {cl: x}
} }

View file

@ -16,7 +16,7 @@ fn main() {
let cheese = ~"roquefort"; let cheese = ~"roquefort";
let carrots = @~"crunchy"; let carrots = @~"crunchy";
let result: &'static fn(@~str, |~str|) = (|tasties, macerate| { let result: 'static |@~str, |~str|| = (|tasties, macerate| {
macerate((*tasties).clone()); macerate((*tasties).clone());
}); });
result(carrots, |food| { result(carrots, |food| {

View file

@ -12,7 +12,7 @@ fn foo() -> int {
return 0xca7f000d; return 0xca7f000d;
} }
struct Bar<'self> { f: &'self fn() -> int } struct Bar<'self> { f: 'self || -> int }
static b : Bar<'static> = Bar { f: foo }; static b : Bar<'static> = Bar { f: foo };

View file

@ -20,7 +20,7 @@
fn f() { } fn f() { }
static bare_fns: &'static [extern fn()] = &[f, 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)]; static closures: &'static [S<'static>] = &[S(f), S(f)];
pub fn main() { pub fn main() {

View file

@ -11,7 +11,7 @@
fn test_fn() { fn test_fn() {
type t = &'static fn() -> int; type t = 'static || -> int;
fn ten() -> int { return 10; } fn ten() -> int { return 10; }
let rs: t = { ten }; let rs: t = { ten };
assert!((rs() == 10)); assert!((rs() == 10));

View file

@ -10,7 +10,7 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
type compare<T> = &'static fn(@T, @T) -> bool; type compare<T> = 'static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) { fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = { expected }; let actual: @T = { expected };

View file

@ -12,7 +12,7 @@
// xfail-fast // xfail-fast
type compare<'self, T> = &'self fn(T, T) -> bool; type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() }; let actual: T = { expected.clone() };

View file

@ -10,7 +10,7 @@
type compare<'self, T> = &'self fn(~T, ~T) -> bool; type compare<'self, T> = 'self |~T, ~T| -> bool;
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) { fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
let actual: ~T = { expected.clone() }; let actual: ~T = { expected.clone() };

View file

@ -10,7 +10,7 @@
// xfail-fast // xfail-fast
type compare<'self, T> = &'self fn(T, T) -> bool; type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() }; let actual: T = { expected.clone() };

View file

@ -12,7 +12,7 @@
// xfail-fast // xfail-fast
// Tests for standalone blocks as expressions with dynamic type sizes // 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<T:Clone>(expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() }; let actual: T = { expected.clone() };

View file

@ -10,7 +10,7 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
type compare<T> = &'static fn(@T, @T) -> bool; type compare<T> = 'static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) { fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) {
let actual: @T = if true { expected } else { not_expected }; let actual: @T = if true { expected } else { not_expected };

View file

@ -12,7 +12,7 @@
// xfail-fast // xfail-fast
type compare<T> = &'static fn(T, T) -> bool; type compare<T> = 'static |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) {
let actual: T = if true { expected.clone() } else { not_expected }; let actual: T = if true { expected.clone() } else { not_expected };

View file

@ -11,7 +11,7 @@
// xfail-fast // xfail-fast
// Tests for if as expressions with dynamic type sizes // Tests for if as expressions with dynamic type sizes
type compare<T> = &'static fn(T, T) -> bool; type compare<T> = 'static |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) {
let actual: T = if true { expected.clone() } else { not_expected }; let actual: T = if true { expected.clone() } else { not_expected };

View file

@ -10,7 +10,7 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
type compare<T> = &'static fn(@T, @T) -> bool; type compare<T> = 'static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) { fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = match true { true => { expected }, _ => fail!() }; let actual: @T = match true { true => { expected }, _ => fail!() };

View file

@ -12,7 +12,7 @@
// xfail-fast // xfail-fast
type compare<T> = &'static fn(T, T) -> bool; type compare<T> = 'static |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") };

View file

@ -10,7 +10,7 @@
type compare<T> = &'static fn(~T, ~T) -> bool; type compare<T> = 'static |~T, ~T| -> bool;
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) { fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
let actual: ~T = match true { let actual: ~T = match true {

View file

@ -10,7 +10,7 @@
// xfail-fast // xfail-fast
type compare<'self, T> = &'self fn(T, T) -> bool; type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) { fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true { let actual: T = match true {

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
struct r<'self> { struct r<'self> {
field: &'self fn() field: 'self ||
} }
pub fn main() { pub fn main() {

View file

@ -24,7 +24,7 @@ mod map_reduce {
use std::str; use std::str;
use std::task; 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); pub type mapper = extern fn(~str, putter);

View file

@ -9,5 +9,5 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let early_error: &'static fn(&str) -> ! = |_msg| { fail!() }; let early_error: 'static |&str| -> ! = |_msg| { fail!() };
} }

View file

@ -18,7 +18,7 @@
// //
// Running /usr/local/bin/rustc: // Running /usr/local/bin/rustc:
// issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait
// issue-2185.rs:24 impl iterable<uint> for &'static fn(|uint|) { // issue-2185.rs:24 impl iterable<uint> for 'static ||uint|| {
// issue-2185.rs:25 fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) } // issue-2185.rs:25 fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) }
// issue-2185.rs:26 } // issue-2185.rs:26 }
// issue-2185.rs:20:0: 22:1 note: note conflicting implementation here // issue-2185.rs:20:0: 22:1 note: note conflicting implementation here

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
type Connection = &'static fn(~[u8]); type Connection = 'static |~[u8]|;
fn f() -> Option<Connection> { fn f() -> Option<Connection> {
let mock_connection: Connection = |_| {}; let mock_connection: Connection = |_| {};

View file

@ -12,10 +12,10 @@
struct A { a: ~int } struct A { a: ~int }
fn foo() -> &'static fn() -> int { fn foo() -> 'static || -> int {
let k = ~22; let k = ~22;
let _u = A {a: k.clone()}; let _u = A {a: k.clone()};
let result: &'static fn() -> int = || 22; let result: 'static || -> int = || 22;
result result
} }

View file

@ -9,10 +9,10 @@
// except according to those terms. // except according to those terms.
struct closure_box<'self> { 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} closure_box {cl: x}
} }

View file

@ -11,9 +11,9 @@
// Test lifetimes are linked properly when we autoslice a vector. // Test lifetimes are linked properly when we autoslice a vector.
// Issue #3148. // 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)) subslice(subslice(v))
} }

View file

@ -9,10 +9,10 @@
// except according to those terms. // except according to those terms.
struct closure_box<'self> { 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} closure_box {cl: x}
} }