mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
librustdoc: Remove fn@
, fn~
, and fn&
from compiletest, fuzzer, rustdoc, and rt. rs=defun
This commit is contained in:
parent
30bb09c0e7
commit
ce3b17badd
@ -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:
|
||||
|
@ -11,8 +11,9 @@
|
||||
use std;
|
||||
use vec;
|
||||
|
||||
fn vec_equal<T>(v: ~[T], u: ~[T],
|
||||
element_equality_test: fn@(&&T, &&T) -> bool) ->
|
||||
fn vec_equal<T>(v: ~[T],
|
||||
u: ~[T],
|
||||
element_equality_test: @fn(&&T, &&T) -> bool) ->
|
||||
bool {
|
||||
let Lv = vec::len(v);
|
||||
if Lv != vec::len(u) { return false; }
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<T: Copy>(
|
||||
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(),
|
||||
|
@ -46,12 +46,12 @@ pub struct Ctxt {
|
||||
ast_map: ast_map::map
|
||||
}
|
||||
|
||||
type SrvOwner<T> = fn(srv: Srv) -> T;
|
||||
pub type CtxtHandler<T> = fn~(ctxt: Ctxt) -> T;
|
||||
type Parser = fn~(Session, s: ~str) -> @ast::crate;
|
||||
type SrvOwner<T> = &fn(srv: Srv) -> T;
|
||||
pub type CtxtHandler<T> = ~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<Msg>, source: ~str, parse: Parser) {
|
||||
|
||||
pub fn exec<T:Owned>(
|
||||
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()
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ fn fold_item(
|
||||
fn parse_item_attrs<T:Owned>(
|
||||
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,
|
||||
|
@ -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");
|
||||
|
@ -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<A>") == ~"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/&")
|
||||
|
@ -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::<WriteInstr>();
|
||||
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 {
|
||||
|
@ -926,7 +926,7 @@ pub struct Crate {
|
||||
|
||||
pub struct Listener {
|
||||
cmds: ~[~str],
|
||||
cb: fn~()
|
||||
cb: ~fn()
|
||||
}
|
||||
|
||||
pub fn run(listeners: ~[Listener]) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user