Skip to content

Commit

Permalink
librustc: Remove remaining uses of &fn() in favor of ||.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Nov 26, 2013
1 parent 4068139 commit 9e61057
Show file tree
Hide file tree
Showing 72 changed files with 163 additions and 153 deletions.
2 changes: 1 addition & 1 deletion doc/po/ja/rust.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down
2 changes: 1 addition & 1 deletion doc/po/rust.md.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down
2 changes: 1 addition & 1 deletion doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
~~~~
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/tvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 6 additions & 7 deletions src/librustc/middle/ty_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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,
Expand All @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/regionmanip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/infer/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/installed_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")) };
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/package_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/path_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustpkg/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/librustpkg/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/librustpkg/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 9e61057

Please sign in to comment.