]> git.lizzy.rs Git - rust.git/commitdiff
Add some tests for obsolete code, sugar used in appropriate ways.
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 27 Nov 2014 11:59:21 +0000 (06:59 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Sun, 14 Dec 2014 09:21:57 +0000 (04:21 -0500)
src/test/compile-fail/obsolete-proc.rs [new file with mode: 0644]
src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs [new file with mode: 0644]
src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs [new file with mode: 0644]
src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/obsolete-proc.rs b/src/test/compile-fail/obsolete-proc.rs
new file mode 100644 (file)
index 0000000..5208cdb
--- /dev/null
@@ -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 (file)
index 0000000..2c1dee3
--- /dev/null
@@ -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 (file)
index 0000000..5e16adc
--- /dev/null
@@ -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 (file)
index 0000000..db94127
--- /dev/null
@@ -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() { }
+