Skip to content

Commit 4bd44be

Browse files
committed
Fix keyword parsing tests
1 parent 9108fb7 commit 4bd44be

36 files changed

+178
-75
lines changed

src/etc/generate-keyword-tests.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@
3434
// option. This file may not be copied, modified, or distributed
3535
// except according to those terms.
3636
37+
// compile-flags: -Z parse-only
38+
3739
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
3840
3941
fn main() {
40-
let %s = "foo"; //~ error: ident
42+
let %s = "foo"; //~ error: expected pattern, found keyword `%s`
4143
}
4244
"""
4345

4446
test_dir = os.path.abspath(
45-
os.path.join(os.path.dirname(__file__), '../test/compile-fail')
47+
os.path.join(os.path.dirname(__file__), '../test/parse-fail')
4648
)
4749

4850
for kw in sys.argv[1:]:
@@ -53,7 +55,7 @@
5355
os.chmod(test_file, stat.S_IWUSR)
5456

5557
with open(test_file, 'wt') as f:
56-
f.write(template % (datetime.datetime.now().year, kw, kw))
58+
f.write(template % (datetime.datetime.now().year, kw, kw, kw))
5759

5860
# mark file read-only
5961
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,10 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test -- FIXME #33010
12-
13-
// This file was auto-generated using 'src/etc/generate-keyword-tests.py false'
14-
1511
fn main() {
16-
let false = "foo"; //~ error: ident
12+
let false = "foo"; //~ error: mismatched types
1713
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,10 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test -- FIXME #33010
12-
13-
// This file was auto-generated using 'src/etc/generate-keyword-tests.py true'
14-
1511
fn main() {
16-
let true = "foo"; //~ error: ident
12+
let true = "foo"; //~ error: mismatched types
1713
}

src/test/parse-fail/keyword-as-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py as'
1414

1515
fn main() {
16-
let as = "foo"; //~ error: ident
16+
let as = "foo"; //~ error: expected pattern, found keyword `as`
1717
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z parse-only
12+
13+
fn main() {
14+
let box = "foo"; //~ error: expected pattern, found `=`
15+
}

src/test/parse-fail/keyword-break-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py break'
1414

1515
fn main() {
16-
let break = "foo"; //~ error: ident
16+
let break = "foo"; //~ error: expected pattern, found keyword `break`
1717
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z parse-only
12+
13+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py const'
14+
15+
fn main() {
16+
let const = "foo"; //~ error: expected pattern, found keyword `const`
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z parse-only
12+
13+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py continue'
14+
15+
fn main() {
16+
let continue = "foo"; //~ error: expected pattern, found keyword `continue`
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z parse-only
12+
13+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py crate'
14+
15+
fn main() {
16+
let crate = "foo"; //~ error: expected pattern, found keyword `crate`
17+
}

src/test/parse-fail/keyword-else-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py else'
1414

1515
fn main() {
16-
let else = "foo"; //~ error: ident
16+
let else = "foo"; //~ error: expected pattern, found keyword `else`
1717
}

src/test/parse-fail/keyword-enum-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum'
1414

1515
fn main() {
16-
let enum = "foo"; //~ error: ident
16+
let enum = "foo"; //~ error: expected pattern, found keyword `enum`
1717
}

src/test/parse-fail/keyword-extern-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py extern'
1414

1515
fn main() {
16-
let extern = "foo"; //~ error: ident
16+
let extern = "foo"; //~ error: expected pattern, found keyword `extern`
1717
}

src/test/parse-fail/keyword-fn-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn'
1414

1515
fn main() {
16-
let fn = "foo"; //~ error: ident
16+
let fn = "foo"; //~ error: expected pattern, found keyword `fn`
1717
}

src/test/parse-fail/keyword-for-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py for'
1414

1515
fn main() {
16-
let for = "foo"; //~ error: ident
16+
let for = "foo"; //~ error: expected pattern, found keyword `for`
1717
}

src/test/parse-fail/keyword-if-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py if'
1414

1515
fn main() {
16-
let if = "foo"; //~ error: ident
16+
let if = "foo"; //~ error: expected pattern, found keyword `if`
1717
}

src/test/parse-fail/keyword-impl-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl'
1414

1515
fn main() {
16-
let impl = "foo"; //~ error: ident
16+
let impl = "foo"; //~ error: expected pattern, found keyword `impl`
1717
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z parse-only
12+
13+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py in'
14+
15+
fn main() {
16+
let in = "foo"; //~ error: expected pattern, found keyword `in`
17+
}

src/test/parse-fail/keyword-let-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py let'
1414

1515
fn main() {
16-
let let = "foo"; //~ error: ident
16+
let let = "foo"; //~ error: expected pattern, found keyword `let`
1717
}

src/test/parse-fail/keyword-loop-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop'
1414

1515
fn main() {
16-
let loop = "foo"; //~ error: ident
16+
let loop = "foo"; //~ error: expected pattern, found keyword `loop`
1717
}

src/test/parse-fail/keyword-match-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py match'
1414

1515
fn main() {
16-
let match = "foo"; //~ error: ident
16+
let match = "foo"; //~ error: expected pattern, found keyword `match`
1717
}

src/test/parse-fail/keyword-mod-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod'
1414

1515
fn main() {
16-
let mod = "foo"; //~ error: ident
16+
let mod = "foo"; //~ error: expected pattern, found keyword `mod`
1717
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z parse-only
12+
13+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py move'
14+
15+
fn main() {
16+
let move = "foo"; //~ error: expected pattern, found keyword `move`
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,8 +10,6 @@
1010

1111
// compile-flags: -Z parse-only
1212

13-
// This file was auto-generated using 'src/etc/generate-keyword-tests.py mut'
14-
1513
fn main() {
16-
let mut = "foo"; //~ error: ident
14+
let mut = "foo"; //~ error: expected identifier, found `=`
1715
}

src/test/parse-fail/keyword-pub-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py pub'
1414

1515
fn main() {
16-
let pub = "foo"; //~ error: ident
16+
let pub = "foo"; //~ error: expected pattern, found keyword `pub`
1717
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,8 +10,6 @@
1010

1111
// compile-flags: -Z parse-only
1212

13-
// This file was auto-generated using 'src/etc/generate-keyword-tests.py ref'
14-
1513
fn main() {
16-
let ref = "foo"; //~ error: ident
14+
let ref = "foo"; //~ error: expected identifier, found `=`
1715
}

src/test/parse-fail/keyword-return-as-identifier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,5 +13,5 @@
1313
// This file was auto-generated using 'src/etc/generate-keyword-tests.py return'
1414

1515
fn main() {
16-
let return = "foo"; //~ error: ident
16+
let return = "foo"; //~ error: expected pattern, found keyword `return`
1717
}

0 commit comments

Comments
 (0)