Skip to content

Commit 7568dd4

Browse files
committed
Promote 'const', 'copy', 'fn' to strict keywords
1 parent 7eb10c4 commit 7568dd4

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn make_test(config: config, testfile: &Path) ->
174174
test::TestDesc {
175175
{
176176
name: make_test_name(config, testfile),
177-
fn: make_test_closure(config, testfile),
177+
testfn: make_test_closure(config, testfile),
178178
ignore: header::is_test_ignored(config, testfile),
179179
should_fail: false
180180
}

src/libstd/test.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type TestFn = fn~();
4545
// these.
4646
type TestDesc = {
4747
name: TestName,
48-
fn: TestFn,
48+
testfn: TestFn,
4949
ignore: bool,
5050
should_fail: bool
5151
};
@@ -238,14 +238,14 @@ fn should_sort_failures_before_printing_them() {
238238
239239
let test_a = {
240240
name: ~"a",
241-
fn: fn~() { },
241+
testfn: fn~() { },
242242
ignore: false,
243243
should_fail: false
244244
};
245245
246246
let test_b = {
247247
name: ~"b",
248-
fn: fn~() { },
248+
testfn: fn~() { },
249249
ignore: false,
250250
should_fail: false
251251
};
@@ -367,7 +367,7 @@ fn filter_tests(opts: TestOpts,
367367
fn filter(test: TestDesc) -> Option<TestDesc> {
368368
if test.ignore {
369369
return option::Some({name: test.name,
370-
fn: copy test.fn,
370+
testfn: copy test.testfn,
371371
ignore: false,
372372
should_fail: test.should_fail});
373373
} else { return option::None; }
@@ -396,7 +396,7 @@ fn run_test(+test: TestDesc, monitor_ch: comm::Chan<MonitorMsg>) {
396396
}
397397
398398
do task::spawn |move test| {
399-
let testfn = copy test.fn;
399+
let testfn = copy test.testfn;
400400
let mut result_future = None; // task::future_result(builder);
401401
task::task().unlinked().future_result(|+r| {
402402
result_future = Some(move r);
@@ -425,7 +425,7 @@ mod tests {
425425
fn f() { fail; }
426426
let desc = {
427427
name: ~"whatever",
428-
fn: f,
428+
testfn: f,
429429
ignore: true,
430430
should_fail: false
431431
};
@@ -441,7 +441,7 @@ mod tests {
441441
fn f() { }
442442
let desc = {
443443
name: ~"whatever",
444-
fn: f,
444+
testfn: f,
445445
ignore: true,
446446
should_fail: false
447447
};
@@ -458,7 +458,7 @@ mod tests {
458458
fn f() { fail; }
459459
let desc = {
460460
name: ~"whatever",
461-
fn: f,
461+
testfn: f,
462462
ignore: false,
463463
should_fail: true
464464
};
@@ -474,7 +474,7 @@ mod tests {
474474
fn f() { }
475475
let desc = {
476476
name: ~"whatever",
477-
fn: f,
477+
testfn: f,
478478
ignore: false,
479479
should_fail: true
480480
};
@@ -513,8 +513,10 @@ mod tests {
513513
let opts = {filter: option::None, run_ignored: true,
514514
logfile: option::None};
515515
let tests =
516-
~[{name: ~"1", fn: fn~() { }, ignore: true, should_fail: false},
517-
{name: ~"2", fn: fn~() { }, ignore: false, should_fail: false}];
516+
~[{name: ~"1", testfn: fn~() { },
517+
ignore: true, should_fail: false},
518+
{name: ~"2", testfn: fn~() { },
519+
ignore: false, should_fail: false}];
518520
let filtered = filter_tests(opts, tests);
519521
520522
assert (vec::len(filtered) == 1u);
@@ -539,7 +541,7 @@ mod tests {
539541
let testfn = fn~() { };
540542
let mut tests = ~[];
541543
for vec::each(names) |name| {
542-
let test = {name: name, fn: copy testfn, ignore: false,
544+
let test = {name: name, testfn: copy testfn, ignore: false,
543545
should_fail: false};
544546
tests += ~[test];
545547
}

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,9 @@ impl parser {
23292329
| ~"owned" => {
23302330
self.obsolete(copy self.span,
23312331
ObsoleteLowerCaseKindBounds);
2332-
None
2332+
// Bogus value, but doesn't matter, since
2333+
// is an error
2334+
Some(bound_send)
23332335
}
23342336

23352337
_ => None

src/libsyntax/parse/token.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@ fn temporary_keyword_table() -> HashMap<~str, ()> {
414414
fn restricted_keyword_table() -> HashMap<~str, ()> {
415415
let words = str_hash();
416416
let keys = ~[
417-
~"const", ~"copy",
418-
~"fail", ~"fn",
417+
~"fail",
419418
~"unsafe"
420419
];
421420
for keys.each |word| {
@@ -430,9 +429,10 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
430429
let keys = ~[
431430
~"as", ~"assert",
432431
~"break",
432+
~"const", ~"copy",
433433
~"do", ~"drop",
434434
~"else", ~"enum", ~"export", ~"extern",
435-
~"false", ~"for",
435+
~"false", ~"fn", ~"for",
436436
~"if", ~"impl",
437437
~"let", ~"log", ~"loop",
438438
~"match", ~"mod", ~"move", ~"mut",

src/rustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
335335
let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span);
336336

337337
let fn_field: ast::field =
338-
nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"fn"),
338+
nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"testfn"),
339339
expr: fn_wrapper_expr});
340340

341341
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));

0 commit comments

Comments
 (0)