Skip to content

Commit 42b0121

Browse files
committed
---
yaml --- r: 78844 b: refs/heads/try c: af99b8d h: refs/heads/master v: v3
1 parent c3eb746 commit 42b0121

33 files changed

+514
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 25ed29a0edb3d48fef843a0b818ee68faf2252da
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 60fba4d7d677ec098e6a43014132fe99f7547363
5-
refs/heads/try: 063d9ca9283efcf1043c7c706c761f20f6f8d9d3
5+
refs/heads/try: af99b8d91e9667b78ac5f7c1eb5ba74764b71fdd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
# xfail-license
3+
# Copyright 2013 The Rust Project Developers. See the COPYRIGHT
4+
# file at the top-level directory of this distribution and at
5+
# http://rust-lang.org/COPYRIGHT.
6+
#
7+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
# option. This file may not be copied, modified, or distributed
11+
# except according to those terms.
12+
"""
13+
This script takes a list of keywords and generates a testcase, that checks
14+
if using the keyword as identifier fails, for every keyword. The generate
15+
test files are set read-only.
16+
Test for https://github.com/mozilla/rust/issues/2275
17+
18+
sample usage: src/etc/generate-keyword-tests.py as break
19+
"""
20+
21+
import sys
22+
import os
23+
import datetime
24+
import stat
25+
26+
27+
template = """// Copyright %d The Rust Project Developers. See the COPYRIGHT
28+
// file at the top-level directory of this distribution and at
29+
// http://rust-lang.org/COPYRIGHT.
30+
//
31+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
32+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
33+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
34+
// option. This file may not be copied, modified, or distributed
35+
// except according to those terms.
36+
37+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
38+
39+
fn main() {
40+
let %s = "foo"; //~ error: ident
41+
}
42+
"""
43+
44+
test_dir = os.path.abspath(
45+
os.path.join(os.path.dirname(__file__), '../test/compile-fail')
46+
)
47+
48+
for kw in sys.argv[1:]:
49+
test_file = os.path.join(test_dir, 'keyword-%s-as-identifier.rs' % kw)
50+
51+
# set write permission if file exists, so it can be changed
52+
if os.path.exists(test_file):
53+
os.chmod(test_file, stat.S_IWUSR)
54+
55+
with open(test_file, 'wt') as f:
56+
f.write(template % (datetime.datetime.now().year, kw, kw))
57+
58+
# mark file read-only
59+
os.chmod(test_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)

branches/try/src/libstd/vec.rs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,11 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
125125
let mut v = with_capacity(n_elts);
126126
let p = raw::to_mut_ptr(v);
127127
let mut i = 0u;
128-
do (|| {
129-
while i < n_elts {
130-
intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)), t.clone());
131-
i += 1u;
132-
}
133-
}).finally {
134-
raw::set_len(&mut v, i);
128+
while i < n_elts {
129+
intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)), t.clone());
130+
i += 1u;
135131
}
132+
raw::set_len(&mut v, n_elts);
136133
v
137134
}
138135
}
@@ -3137,29 +3134,6 @@ mod tests {
31373134
};
31383135
}
31393136

3140-
#[test]
3141-
#[should_fail]
3142-
fn test_from_elem_fail() {
3143-
use cast;
3144-
3145-
struct S {
3146-
f: int,
3147-
boxes: (~int, @int)
3148-
}
3149-
3150-
impl Clone for S {
3151-
fn clone(&self) -> S {
3152-
let s = unsafe { cast::transmute_mut(self) };
3153-
s.f += 1;
3154-
if s.f == 10 { fail!() }
3155-
S { f: s.f, boxes: s.boxes.clone() }
3156-
}
3157-
}
3158-
3159-
let s = S { f: 0, boxes: (~0, @0) };
3160-
let _ = from_elem(100, s);
3161-
}
3162-
31633137
#[test]
31643138
#[should_fail]
31653139
fn test_build_fail() {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py as'
12+
13+
fn main() {
14+
let as = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py break'
12+
13+
fn main() {
14+
let break = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py do'
12+
13+
fn main() {
14+
let do = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py else'
12+
13+
fn main() {
14+
let else = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum'
12+
13+
fn main() {
14+
let enum = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py extern'
12+
13+
fn main() {
14+
let extern = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py false'
12+
13+
fn main() {
14+
let false = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn'
12+
13+
fn main() {
14+
let fn = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py for'
12+
13+
fn main() {
14+
let for = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py if'
12+
13+
fn main() {
14+
let if = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl'
12+
13+
fn main() {
14+
let impl = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py let'
12+
13+
fn main() {
14+
let let = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop'
12+
13+
fn main() {
14+
let loop = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py match'
12+
13+
fn main() {
14+
let match = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod'
12+
13+
fn main() {
14+
let mod = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py mut'
12+
13+
fn main() {
14+
let mut = "foo"; //~ error: ident
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// This file was auto-generated using 'src/etc/generate-keyword-tests.py priv'
12+
13+
fn main() {
14+
let priv = "foo"; //~ error: ident
15+
}

0 commit comments

Comments
 (0)