diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index ae5cb1e6f11..bccaf0ddf60 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -223,7 +223,7 @@ pub fn make_test_name(config: config, testfile: &Path) -> test::TestName { pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { let testfile = testfile.to_str(); - test::DynTestFn(fn~() { runtest::run(config, testfile) }) + test::DynTestFn(|| runtest::run(config, testfile)) } // Local Variables: diff --git a/src/libfuzzer/ast_match.rs b/src/libfuzzer/ast_match.rs index 417141fd865..afbe0c930cc 100644 --- a/src/libfuzzer/ast_match.rs +++ b/src/libfuzzer/ast_match.rs @@ -11,8 +11,9 @@ use std; use vec; -fn vec_equal(v: ~[T], u: ~[T], - element_equality_test: fn@(&&T, &&T) -> bool) -> +fn vec_equal(v: ~[T], + u: ~[T], + element_equality_test: @fn(&&T, &&T) -> bool) -> bool { let Lv = vec::len(v); if Lv != vec::len(u) { return false; } diff --git a/src/libfuzzer/cycles.rs b/src/libfuzzer/cycles.rs index 7288b6d261d..fb4c6400434 100644 --- a/src/libfuzzer/cycles.rs +++ b/src/libfuzzer/cycles.rs @@ -39,8 +39,8 @@ type pointy = { mut b : ~maybe_pointy, mut c : @maybe_pointy, - mut f : fn@()->(), - mut g : fn~()->(), + mut f : @fn()->(), + mut g : ~fn()->(), mut m : ~[maybe_pointy], mut n : ~[maybe_pointy], @@ -54,8 +54,8 @@ fn empty_pointy() -> @pointy { mut b : ~none, mut c : @none, - mut f : fn@()->(){}, - mut g : fn~()->(){}, + mut f : || {}, + mut g : || {}, mut m : ~[], mut n : ~[], @@ -82,7 +82,7 @@ fn test_cycles(r : rand::rng, k: uint, n: uint) if (likelihood(r, k, n)) { v[i].c = @p(choice(r, v)); } if (likelihood(r, k, n)) { v[i].f = bind nopP(choice(r, v)); } - //if (false) { v[i].g = bind (fn~(_x: @pointy) { })( + //if (false) { v[i].g = bind (|_: @pointy| { })( // choice(r, v)); } // https://github.com/mozilla/rust/issues/1899 diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 3714b6763c6..1eb4ff98a6e 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -137,7 +137,7 @@ pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool { } // Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED) -pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, +pub fn stash_expr_if(c: @fn(@ast::expr, test_mode)->bool, es: @mut ~[ast::expr], e: @ast::expr, tm: test_mode) { @@ -148,7 +148,7 @@ pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, } } -pub fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool, +pub fn stash_ty_if(c: @fn(@ast::Ty, test_mode)->bool, es: @mut ~[ast::Ty], e: @ast::Ty, tm: test_mode) { @@ -252,7 +252,7 @@ pub fn under(n: uint, it: fn(uint)) { while i < n { it(i); i += 1u; } } -pub fn as_str(f: fn@(+x: io::Writer)) -> ~str { +pub fn as_str(f: @fn(+x: io::Writer)) -> ~str { io::with_str_writer(f) } @@ -275,8 +275,8 @@ pub fn check_variants_T( filename: &Path, thing_label: ~str, things: ~[T], - stringifier: fn@(@T, @syntax::parse::token::ident_interner) -> ~str, - replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate, + stringifier: @fn(@T, @syntax::parse::token::ident_interner) -> ~str, + replacer: @fn(ast::crate, uint, T, test_mode) -> ast::crate, cx: Context ) { error!("%s contains %u %s objects", filename.to_str(), diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index 1c45fdafa18..03410ee30fc 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -46,12 +46,12 @@ pub struct Ctxt { ast_map: ast_map::map } -type SrvOwner = fn(srv: Srv) -> T; -pub type CtxtHandler = fn~(ctxt: Ctxt) -> T; -type Parser = fn~(Session, s: ~str) -> @ast::crate; +type SrvOwner = &fn(srv: Srv) -> T; +pub type CtxtHandler = ~fn(ctxt: Ctxt) -> T; +type Parser = ~fn(Session, s: ~str) -> @ast::crate; enum Msg { - HandleRequest(fn~(Ctxt)), + HandleRequest(~fn(Ctxt)), Exit } @@ -117,12 +117,10 @@ fn act(po: &Port, source: ~str, parse: Parser) { pub fn exec( srv: Srv, - f: fn~(ctxt: Ctxt) -> T + f: ~fn(ctxt: Ctxt) -> T ) -> T { let (po, ch) = stream(); - let msg = HandleRequest(fn~(ctxt: Ctxt) { - ch.send(f(ctxt)) - }); + let msg = HandleRequest(|ctxt| ch.send(f(ctxt))); srv.ch.send(msg); po.recv() } diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 85ac952d6d4..28322450c4d 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -114,7 +114,7 @@ fn fold_item( fn parse_item_attrs( srv: astsrv::Srv, id: doc::AstId, - parse_attrs: fn~(a: ~[ast::attribute]) -> T) -> T { + parse_attrs: ~fn(a: ~[ast::attribute]) -> T) -> T { do astsrv::exec(srv) |ctxt| { let attrs = match ctxt.ast_map.get(&id) { ast_map::node_item(item, _) => copy item.attrs, diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 50c7b94078b..21c0393f68f 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -105,7 +105,7 @@ pub fn default_config(input_crate: &Path) -> Config { } } -type Process = fn~((&str), (&[~str])) -> ProgramOutput; +type Process = ~fn((&str), (&[~str])) -> ProgramOutput; pub fn mock_program_output(_prog: &str, _args: &[~str]) -> ProgramOutput { ProgramOutput { @@ -262,11 +262,8 @@ fn should_find_pandoc() { output_format: PandocHtml, .. default_config(&Path("test")) }; - let mock_program_output = fn~(_prog: &str, _args: &[~str]) - -> ProgramOutput { - ProgramOutput { - status: 0, out: ~"pandoc 1.8.2.1", err: ~"" - } + let mock_program_output: ~fn(&str, &[~str]) -> ProgramOutput = |prog, _| { + ProgramOutput { status: 0, out: ~"pandoc 1.8.2.1", err: ~"" } }; let result = maybe_find_pandoc(&config, None, mock_program_output); assert result == result::Ok(Some(~"pandoc")); @@ -278,11 +275,8 @@ fn should_error_with_no_pandoc() { output_format: PandocHtml, .. default_config(&Path("test")) }; - let mock_program_output = fn~(_prog: &str, _args: &[~str]) - -> ProgramOutput { - ProgramOutput { - status: 1, out: ~"", err: ~"" - } + let mock_program_output: ~fn(&str, &[~str]) -> ProgramOutput = |_, _| { + ProgramOutput { status: 1, out: ~"", err: ~"" } }; let result = maybe_find_pandoc(&config, None, mock_program_output); assert result == result::Err(~"couldn't find pandoc"); diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index 42a7d0006db..b37f8f8443e 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -162,7 +162,6 @@ fn pandoc_header_id(header: &str) -> ~str { #[test] fn should_remove_punctuation_from_headers() { assert pandoc_header_id(~"impl foo of bar") == ~"impl-foo-of-bara"; - assert pandoc_header_id(~"fn@(~[~A])") == ~"fna"; assert pandoc_header_id(~"impl of num::num for int") == ~"impl-of-numnum-for-int"; assert pandoc_header_id(~"impl of num::num for int/&") diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index b57d8416aab..020073f9b89 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -34,8 +34,8 @@ pub enum WriteInstr { Done } -pub type Writer = fn~(v: WriteInstr); -pub type WriterFactory = fn~(page: doc::Page) -> Writer; +pub type Writer = ~fn(v: WriteInstr); +pub type WriterFactory = ~fn(page: doc::Page) -> Writer; pub trait WriterUtils { fn write_str(&self, +str: ~str); @@ -69,15 +69,17 @@ pub fn make_writer_factory(config: config::Config) -> WriterFactory { } fn markdown_writer_factory(config: config::Config) -> WriterFactory { - fn~(page: doc::Page) -> Writer { + let result: ~fn(page: doc::Page) -> Writer = |page| { markdown_writer(copy config, page) - } + }; + result } fn pandoc_writer_factory(config: config::Config) -> WriterFactory { - fn~(page: doc::Page) -> Writer { + let result: ~fn(doc::Page) -> Writer = |page| { pandoc_writer(copy config, page) - } + }; + result } fn markdown_writer( @@ -167,7 +169,7 @@ fn readclose(fd: libc::c_int) -> ~str { } } -fn generic_writer(process: fn~(markdown: ~str)) -> Writer { +fn generic_writer(process: ~fn(markdown: ~str)) -> Writer { let (po, ch) = stream::(); do task::spawn || { let mut markdown = ~""; @@ -180,9 +182,8 @@ fn generic_writer(process: fn~(markdown: ~str)) -> Writer { } process(markdown); }; - fn~(instr: WriteInstr) { - ch.send(instr); - } + let result: ~fn(instr: WriteInstr) = |instr| ch.send(instr); + result } fn make_local_filename( @@ -295,7 +296,7 @@ pub fn future_writer_factory( ) -> (WriterFactory, Port<(doc::Page, ~str)>) { let (markdown_po, markdown_ch) = stream(); let markdown_ch = SharedChan(markdown_ch); - let writer_factory = fn~(page: doc::Page) -> Writer { + let writer_factory: WriterFactory = |page| { let (writer_po, writer_ch) = comm::stream(); let markdown_ch = markdown_ch.clone(); do task::spawn || { @@ -312,9 +313,7 @@ pub fn future_writer_factory( fn future_writer() -> (Writer, future::Future<~str>) { let (port, chan) = comm::stream(); - let writer = fn~(instr: WriteInstr) { - chan.send(copy instr); - }; + let writer: ~fn(instr: WriteInstr) = |instr| chan.send(copy instr); let future = do future::from_fn || { let mut res = ~""; loop { diff --git a/src/librustpkg/rustpkg.rc b/src/librustpkg/rustpkg.rc index cc045851539..603480f907c 100644 --- a/src/librustpkg/rustpkg.rc +++ b/src/librustpkg/rustpkg.rc @@ -926,7 +926,7 @@ pub struct Crate { pub struct Listener { cmds: ~[~str], - cb: fn~() + cb: ~fn() } pub fn run(listeners: ~[Listener]) { diff --git a/src/rt/rust_type.h b/src/rt/rust_type.h index b631cfa35f4..ece0d48c3ae 100644 --- a/src/rt/rust_type.h +++ b/src/rt/rust_type.h @@ -36,7 +36,7 @@ struct rust_opaque_box { rust_opaque_box *next; }; -// corresponds to the layout of a fn(), fn@(), fn~() etc +// corresponds to the layout of a &fn(), @fn(), ~fn() etc struct fn_env_pair { spawn_fn f; rust_opaque_box *env;