diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-11-27 06:59:21 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-14 04:21:57 -0500 |
| commit | 9c9253e859c8a7d1cf522e56bca09502bda38573 (patch) | |
| tree | a0d5376eab5c6a3066b299ca9417cf40b09bc043 | |
| parent | 0fefd835f22adfd73e735dd6ee2b5e541291d636 (diff) | |
| download | rust-9c9253e859c8a7d1cf522e56bca09502bda38573.tar.gz rust-9c9253e859c8a7d1cf522e56bca09502bda38573.zip | |
Add some tests for obsolete code, sugar used in appropriate ways.
4 files changed, 92 insertions, 0 deletions
diff --git a/src/test/compile-fail/obsolete-proc.rs b/src/test/compile-fail/obsolete-proc.rs new file mode 100644 index 00000000000..5208cdb6ad2 --- /dev/null +++ b/src/test/compile-fail/obsolete-proc.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we generate obsolete syntax errors around usages of `proc`. + +fn foo(p: proc()) { } //~ ERROR obsolete syntax: the `proc` type + +fn bar() { proc() 1; } //~ ERROR obsolete syntax: `proc` expression + +fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs new file mode 100644 index 00000000000..2c1dee36b9a --- /dev/null +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// Test that parentheses form doesn't work with struct types appearing in local variables. + +struct Bar<A,R> { + f: A, r: R +} + +fn bar() { + let x: Box<Bar()> = panic!(); + //~^ ERROR E0169 +} + +fn main() { } + diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs new file mode 100644 index 00000000000..5e16adc4e42 --- /dev/null +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that parentheses form doesn't work in expression paths. + +struct Bar<A,R> { + f: A, r: R +} + +impl<A,B> Bar<A,B> { + fn new() -> Bar<A,B> { panic!() } +} + +fn bar() { + let b = Box::Bar::<int,uint>::new(); // OK + + let b = Box::Bar::()::new(); + //~^ ERROR expected ident, found `(` +} + +fn main() { } + diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs new file mode 100644 index 00000000000..db94127a9ea --- /dev/null +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that parentheses form doesn't work with struct types appearing in argument types. + +struct Bar<A,R> { + f: A, r: R +} + +fn foo(b: Box<Bar()>) { + //~^ ERROR E0169 +} + +fn main() { } + |
