Skip to content

Commit ce3b17b

Browse files
committed
librustdoc: Remove fn@, fn~, and fn& from compiletest, fuzzer, rustdoc, and rt. rs=defun
1 parent 30bb09c commit ce3b17b

File tree

11 files changed

+41
-50
lines changed

11 files changed

+41
-50
lines changed

src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn make_test_name(config: config, testfile: &Path) -> test::TestName {
223223

224224
pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
225225
let testfile = testfile.to_str();
226-
test::DynTestFn(fn~() { runtest::run(config, testfile) })
226+
test::DynTestFn(|| runtest::run(config, testfile))
227227
}
228228

229229
// Local Variables:

src/libfuzzer/ast_match.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
use std;
1212
use vec;
1313

14-
fn vec_equal<T>(v: ~[T], u: ~[T],
15-
element_equality_test: fn@(&&T, &&T) -> bool) ->
14+
fn vec_equal<T>(v: ~[T],
15+
u: ~[T],
16+
element_equality_test: @fn(&&T, &&T) -> bool) ->
1617
bool {
1718
let Lv = vec::len(v);
1819
if Lv != vec::len(u) { return false; }

src/libfuzzer/cycles.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ type pointy = {
3939
mut b : ~maybe_pointy,
4040
mut c : @maybe_pointy,
4141

42-
mut f : fn@()->(),
43-
mut g : fn~()->(),
42+
mut f : @fn()->(),
43+
mut g : ~fn()->(),
4444

4545
mut m : ~[maybe_pointy],
4646
mut n : ~[maybe_pointy],
@@ -54,8 +54,8 @@ fn empty_pointy() -> @pointy {
5454
mut b : ~none,
5555
mut c : @none,
5656

57-
mut f : fn@()->(){},
58-
mut g : fn~()->(){},
57+
mut f : || {},
58+
mut g : || {},
5959

6060
mut m : ~[],
6161
mut n : ~[],
@@ -82,7 +82,7 @@ fn test_cycles(r : rand::rng, k: uint, n: uint)
8282
if (likelihood(r, k, n)) { v[i].c = @p(choice(r, v)); }
8383

8484
if (likelihood(r, k, n)) { v[i].f = bind nopP(choice(r, v)); }
85-
//if (false) { v[i].g = bind (fn~(_x: @pointy) { })(
85+
//if (false) { v[i].g = bind (|_: @pointy| { })(
8686
// choice(r, v)); }
8787
// https://github.com/mozilla/rust/issues/1899
8888

src/libfuzzer/fuzzer.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool {
137137
}
138138

139139
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
140-
pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
140+
pub fn stash_expr_if(c: @fn(@ast::expr, test_mode)->bool,
141141
es: @mut ~[ast::expr],
142142
e: @ast::expr,
143143
tm: test_mode) {
@@ -148,7 +148,7 @@ pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
148148
}
149149
}
150150

151-
pub fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool,
151+
pub fn stash_ty_if(c: @fn(@ast::Ty, test_mode)->bool,
152152
es: @mut ~[ast::Ty],
153153
e: @ast::Ty,
154154
tm: test_mode) {
@@ -252,7 +252,7 @@ pub fn under(n: uint, it: fn(uint)) {
252252
while i < n { it(i); i += 1u; }
253253
}
254254

255-
pub fn as_str(f: fn@(+x: io::Writer)) -> ~str {
255+
pub fn as_str(f: @fn(+x: io::Writer)) -> ~str {
256256
io::with_str_writer(f)
257257
}
258258

@@ -275,8 +275,8 @@ pub fn check_variants_T<T: Copy>(
275275
filename: &Path,
276276
thing_label: ~str,
277277
things: ~[T],
278-
stringifier: fn@(@T, @syntax::parse::token::ident_interner) -> ~str,
279-
replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate,
278+
stringifier: @fn(@T, @syntax::parse::token::ident_interner) -> ~str,
279+
replacer: @fn(ast::crate, uint, T, test_mode) -> ast::crate,
280280
cx: Context
281281
) {
282282
error!("%s contains %u %s objects", filename.to_str(),

src/librustdoc/astsrv.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ pub struct Ctxt {
4646
ast_map: ast_map::map
4747
}
4848

49-
type SrvOwner<T> = fn(srv: Srv) -> T;
50-
pub type CtxtHandler<T> = fn~(ctxt: Ctxt) -> T;
51-
type Parser = fn~(Session, s: ~str) -> @ast::crate;
49+
type SrvOwner<T> = &fn(srv: Srv) -> T;
50+
pub type CtxtHandler<T> = ~fn(ctxt: Ctxt) -> T;
51+
type Parser = ~fn(Session, s: ~str) -> @ast::crate;
5252

5353
enum Msg {
54-
HandleRequest(fn~(Ctxt)),
54+
HandleRequest(~fn(Ctxt)),
5555
Exit
5656
}
5757

@@ -117,12 +117,10 @@ fn act(po: &Port<Msg>, source: ~str, parse: Parser) {
117117

118118
pub fn exec<T:Owned>(
119119
srv: Srv,
120-
f: fn~(ctxt: Ctxt) -> T
120+
f: ~fn(ctxt: Ctxt) -> T
121121
) -> T {
122122
let (po, ch) = stream();
123-
let msg = HandleRequest(fn~(ctxt: Ctxt) {
124-
ch.send(f(ctxt))
125-
});
123+
let msg = HandleRequest(|ctxt| ch.send(f(ctxt)));
126124
srv.ch.send(msg);
127125
po.recv()
128126
}

src/librustdoc/attr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn fold_item(
114114
fn parse_item_attrs<T:Owned>(
115115
srv: astsrv::Srv,
116116
id: doc::AstId,
117-
parse_attrs: fn~(a: ~[ast::attribute]) -> T) -> T {
117+
parse_attrs: ~fn(a: ~[ast::attribute]) -> T) -> T {
118118
do astsrv::exec(srv) |ctxt| {
119119
let attrs = match ctxt.ast_map.get(&id) {
120120
ast_map::node_item(item, _) => copy item.attrs,

src/librustdoc/config.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn default_config(input_crate: &Path) -> Config {
105105
}
106106
}
107107

108-
type Process = fn~((&str), (&[~str])) -> ProgramOutput;
108+
type Process = ~fn((&str), (&[~str])) -> ProgramOutput;
109109

110110
pub fn mock_program_output(_prog: &str, _args: &[~str]) -> ProgramOutput {
111111
ProgramOutput {
@@ -262,11 +262,8 @@ fn should_find_pandoc() {
262262
output_format: PandocHtml,
263263
.. default_config(&Path("test"))
264264
};
265-
let mock_program_output = fn~(_prog: &str, _args: &[~str])
266-
-> ProgramOutput {
267-
ProgramOutput {
268-
status: 0, out: ~"pandoc 1.8.2.1", err: ~""
269-
}
265+
let mock_program_output: ~fn(&str, &[~str]) -> ProgramOutput = |prog, _| {
266+
ProgramOutput { status: 0, out: ~"pandoc 1.8.2.1", err: ~"" }
270267
};
271268
let result = maybe_find_pandoc(&config, None, mock_program_output);
272269
assert result == result::Ok(Some(~"pandoc"));
@@ -278,11 +275,8 @@ fn should_error_with_no_pandoc() {
278275
output_format: PandocHtml,
279276
.. default_config(&Path("test"))
280277
};
281-
let mock_program_output = fn~(_prog: &str, _args: &[~str])
282-
-> ProgramOutput {
283-
ProgramOutput {
284-
status: 1, out: ~"", err: ~""
285-
}
278+
let mock_program_output: ~fn(&str, &[~str]) -> ProgramOutput = |_, _| {
279+
ProgramOutput { status: 1, out: ~"", err: ~"" }
286280
};
287281
let result = maybe_find_pandoc(&config, None, mock_program_output);
288282
assert result == result::Err(~"couldn't find pandoc");

src/librustdoc/markdown_index_pass.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ fn pandoc_header_id(header: &str) -> ~str {
162162
#[test]
163163
fn should_remove_punctuation_from_headers() {
164164
assert pandoc_header_id(~"impl foo of bar<A>") == ~"impl-foo-of-bara";
165-
assert pandoc_header_id(~"fn@(~[~A])") == ~"fna";
166165
assert pandoc_header_id(~"impl of num::num for int")
167166
== ~"impl-of-numnum-for-int";
168167
assert pandoc_header_id(~"impl of num::num for int/&")

src/librustdoc/markdown_writer.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub enum WriteInstr {
3434
Done
3535
}
3636

37-
pub type Writer = fn~(v: WriteInstr);
38-
pub type WriterFactory = fn~(page: doc::Page) -> Writer;
37+
pub type Writer = ~fn(v: WriteInstr);
38+
pub type WriterFactory = ~fn(page: doc::Page) -> Writer;
3939

4040
pub trait WriterUtils {
4141
fn write_str(&self, +str: ~str);
@@ -69,15 +69,17 @@ pub fn make_writer_factory(config: config::Config) -> WriterFactory {
6969
}
7070

7171
fn markdown_writer_factory(config: config::Config) -> WriterFactory {
72-
fn~(page: doc::Page) -> Writer {
72+
let result: ~fn(page: doc::Page) -> Writer = |page| {
7373
markdown_writer(copy config, page)
74-
}
74+
};
75+
result
7576
}
7677

7778
fn pandoc_writer_factory(config: config::Config) -> WriterFactory {
78-
fn~(page: doc::Page) -> Writer {
79+
let result: ~fn(doc::Page) -> Writer = |page| {
7980
pandoc_writer(copy config, page)
80-
}
81+
};
82+
result
8183
}
8284

8385
fn markdown_writer(
@@ -167,7 +169,7 @@ fn readclose(fd: libc::c_int) -> ~str {
167169
}
168170
}
169171
170-
fn generic_writer(process: fn~(markdown: ~str)) -> Writer {
172+
fn generic_writer(process: ~fn(markdown: ~str)) -> Writer {
171173
let (po, ch) = stream::<WriteInstr>();
172174
do task::spawn || {
173175
let mut markdown = ~"";
@@ -180,9 +182,8 @@ fn generic_writer(process: fn~(markdown: ~str)) -> Writer {
180182
}
181183
process(markdown);
182184
};
183-
fn~(instr: WriteInstr) {
184-
ch.send(instr);
185-
}
185+
let result: ~fn(instr: WriteInstr) = |instr| ch.send(instr);
186+
result
186187
}
187188
188189
fn make_local_filename(
@@ -295,7 +296,7 @@ pub fn future_writer_factory(
295296
) -> (WriterFactory, Port<(doc::Page, ~str)>) {
296297
let (markdown_po, markdown_ch) = stream();
297298
let markdown_ch = SharedChan(markdown_ch);
298-
let writer_factory = fn~(page: doc::Page) -> Writer {
299+
let writer_factory: WriterFactory = |page| {
299300
let (writer_po, writer_ch) = comm::stream();
300301
let markdown_ch = markdown_ch.clone();
301302
do task::spawn || {
@@ -312,9 +313,7 @@ pub fn future_writer_factory(
312313
313314
fn future_writer() -> (Writer, future::Future<~str>) {
314315
let (port, chan) = comm::stream();
315-
let writer = fn~(instr: WriteInstr) {
316-
chan.send(copy instr);
317-
};
316+
let writer: ~fn(instr: WriteInstr) = |instr| chan.send(copy instr);
318317
let future = do future::from_fn || {
319318
let mut res = ~"";
320319
loop {

src/librustpkg/rustpkg.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ pub struct Crate {
926926

927927
pub struct Listener {
928928
cmds: ~[~str],
929-
cb: fn~()
929+
cb: ~fn()
930930
}
931931

932932
pub fn run(listeners: ~[Listener]) {

src/rt/rust_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct rust_opaque_box {
3636
rust_opaque_box *next;
3737
};
3838

39-
// corresponds to the layout of a fn(), fn@(), fn~() etc
39+
// corresponds to the layout of a &fn(), @fn(), ~fn() etc
4040
struct fn_env_pair {
4141
spawn_fn f;
4242
rust_opaque_box *env;

0 commit comments

Comments
 (0)