Skip to content

Commit 9c9253e

Browse files
committed
Add some tests for obsolete code, sugar used in appropriate ways.
1 parent 0fefd83 commit 9c9253e

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 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+
// Test that we generate obsolete syntax errors around usages of `proc`.
12+
13+
fn foo(p: proc()) { } //~ ERROR obsolete syntax: the `proc` type
14+
15+
fn bar() { proc() 1; } //~ ERROR obsolete syntax: `proc` expression
16+
17+
fn main() { }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 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+
12+
// Test that parentheses form doesn't work with struct types appearing in local variables.
13+
14+
struct Bar<A,R> {
15+
f: A, r: R
16+
}
17+
18+
fn bar() {
19+
let x: Box<Bar()> = panic!();
20+
//~^ ERROR E0169
21+
}
22+
23+
fn main() { }
24+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 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+
// Test that parentheses form doesn't work in expression paths.
12+
13+
struct Bar<A,R> {
14+
f: A, r: R
15+
}
16+
17+
impl<A,B> Bar<A,B> {
18+
fn new() -> Bar<A,B> { panic!() }
19+
}
20+
21+
fn bar() {
22+
let b = Box::Bar::<int,uint>::new(); // OK
23+
24+
let b = Box::Bar::()::new();
25+
//~^ ERROR expected ident, found `(`
26+
}
27+
28+
fn main() { }
29+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 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+
// Test that parentheses form doesn't work with struct types appearing in argument types.
12+
13+
struct Bar<A,R> {
14+
f: A, r: R
15+
}
16+
17+
fn foo(b: Box<Bar()>) {
18+
//~^ ERROR E0169
19+
}
20+
21+
fn main() { }
22+

0 commit comments

Comments
 (0)