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
#: 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 ""

View File

@ -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 ""

View File

@ -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);
~~~~

View File

@ -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.

View File

@ -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

View File

@ -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<ebml::Doc> {
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<ast::inlined_item>;
pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata,
tcx: ty::ctxt,
path: ast_map::path,
par_doc: ebml::Doc|
-> Option<ast::inlined_item>;
pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt,
id: ast::NodeId,

View File

@ -52,10 +52,10 @@ use std::cast;
// used by astencode:
type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>;
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,

View File

@ -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<Path> {
if path.filename() == Some(file.as_vec()) {

View File

@ -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],

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,
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 {
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;
}
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 {

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,
data_ptr: ValueRef,

View File

@ -224,7 +224,7 @@ pub fn super_fold_trait_store<T:TypeFolder>(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 }

View File

@ -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

View File

@ -52,7 +52,7 @@ pub trait LatticeValue {
}
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 {
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)]
pub enum LatticeVarResult<V,T> {

View File

@ -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,
}

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,
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();

View File

@ -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<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 {
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

View File

@ -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")) };

View File

@ -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();

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,
// 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() {
return None;
}

View File

@ -94,7 +94,7 @@ fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(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 <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();
self.next(1)[0] = 128;

View File

@ -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,

View File

@ -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);

View File

@ -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

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
/// // 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<V>(&self, inner: &'self fn() -> V) -> V {
pub fn inside<V>(&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);

View File

@ -156,7 +156,7 @@ pub trait Iterator<A> {
/// 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<A> {
/// 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<A> {
/// assert!(it.next().is_none());
/// ```
#[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 }
}
@ -249,7 +249,7 @@ pub trait Iterator<A> {
/// 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<A> {
/// 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<A> {
/// assert!(it.next().is_none());
/// ```
#[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{iter: self, f: f, state: initial_state}
}
@ -349,7 +349,7 @@ pub trait Iterator<A> {
/// }
/// ```
#[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{iter: self, f: f, frontiter: None, backiter: None }
}
@ -401,7 +401,7 @@ pub trait Iterator<A> {
///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<T, U> {
/// 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<A>> RandomAccessIterator<B> 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<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`
pub struct FilterMap<'self, A, B, 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> {
@ -1359,7 +1359,7 @@ impl<'self, A, T: Iterator<A>> Peekable<A, T> {
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<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> {
priv iter: T,
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> {
@ -1544,7 +1544,7 @@ impl<A, T: RandomAccessIterator<A>> RandomAccessIterator<A> for Take<T> {
/// 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<B>,
priv f: 'self |&mut St, A| -> Option<B>,
/// The current internal state to be passed to the closure next.
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> {
priv iter: T,
priv f: &'self fn(A) -> U,
priv f: 'self |A| -> U,
priv frontiter: Option<U>,
priv backiter: Option<U>,
}
@ -1699,7 +1699,7 @@ impl<T> Fuse<T> {
/// 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<A>,
priv f: 'self |&mut St| -> Option<A>,
/// 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<A>)
-> Unfold<'a, A, St> {
pub fn new<'a>(initial_state: St, f: 'a |&mut St| -> Option<A>)
-> Unfold<'a, A, St> {
Unfold {
f: f,
state: initial_state

View File

@ -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<R:Rng>(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<R:Rng>(
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

View File

@ -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) }

View File

@ -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;

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

View File

@ -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> {

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.
*/
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<Ident>, @Expr)])],
&[@Expr]) -> @Expr;
'self |@ExtCtxt,
Span,
&[(uint, ast::variant, ~[(Span, Option<Ident>, @Expr)])],
&[@Expr]|
-> @Expr;
impl<'self> TraitDef<'self> {

View File

@ -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,

View File

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

View File

@ -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<T> for Iterate<'self, T> {

View File

@ -10,7 +10,9 @@
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() {
let v = &5;

View File

@ -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();

View File

@ -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() {

View File

@ -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;

View File

@ -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 }

View File

@ -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>) {

View File

@ -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>) {

View File

@ -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

View File

@ -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}
}

View File

@ -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| {

View File

@ -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 };

View File

@ -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() {

View File

@ -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));

View File

@ -10,7 +10,7 @@
#[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>) {
let actual: @T = { expected };

View File

@ -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<T:Clone>(expected: T, eq: compare<T>) {
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>) {
let actual: ~T = { expected.clone() };

View File

@ -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<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() };

View File

@ -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<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() };

View File

@ -10,7 +10,7 @@
#[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>) {
let actual: @T = if true { expected } else { not_expected };

View File

@ -12,7 +12,7 @@
// 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>) {
let actual: T = if true { expected.clone() } else { not_expected };

View File

@ -11,7 +11,7 @@
// xfail-fast
// 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>) {
let actual: T = if true { expected.clone() } else { not_expected };

View File

@ -10,7 +10,7 @@
#[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>) {
let actual: @T = match true { true => { expected }, _ => fail!() };

View File

@ -12,7 +12,7 @@
// 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>) {
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>) {
let actual: ~T = match true {

View File

@ -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<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true {

View File

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

View File

@ -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);

View File

@ -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!() };
}

View File

@ -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<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:26 }
// 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
// except according to those terms.
type Connection = &'static fn(~[u8]);
type Connection = 'static |~[u8]|;
fn f() -> Option<Connection> {
let mock_connection: Connection = |_| {};

View File

@ -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
}

View File

@ -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}
}

View File

@ -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))
}

View File

@ -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}
}