]> git.lizzy.rs Git - rust.git/commitdiff
Tests for issue 5997 failure and success conditions.
authorKevin Butler <haqkrs@gmail.com>
Tue, 15 Apr 2014 04:58:22 +0000 (05:58 +0100)
committerKevin Butler <haqkrs@gmail.com>
Thu, 17 Apr 2014 17:24:51 +0000 (18:24 +0100)
Closes #5997.

src/test/compile-fail/issue-5997-enum.rs [new file with mode: 0644]
src/test/compile-fail/issue-5997-struct.rs [new file with mode: 0644]
src/test/run-pass/issue-5997.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/issue-5997-enum.rs b/src/test/compile-fail/issue-5997-enum.rs
new file mode 100644 (file)
index 0000000..d74bb39
--- /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.
+
+// error-pattern: missing type param `Z` in the substitution of `Z`
+
+fn f<Z>() -> bool {
+    enum E { V(Z) }
+
+    true
+}
+
+fn main() {
+    let b = f::<int>();
+    assert!(b);
+}
diff --git a/src/test/compile-fail/issue-5997-struct.rs b/src/test/compile-fail/issue-5997-struct.rs
new file mode 100644 (file)
index 0000000..ad31b85
--- /dev/null
@@ -0,0 +1,21 @@
+// 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.
+
+fn f<T>() -> bool {
+    struct S(T); //~ ERROR use of undeclared type name `T`
+    //~^ ERROR attempt to use a type argument out of scope
+
+    true
+}
+
+fn main() {
+    let b = f::<int>();
+    assert!(b);
+}
diff --git a/src/test/run-pass/issue-5997.rs b/src/test/run-pass/issue-5997.rs
new file mode 100644 (file)
index 0000000..9e2a001
--- /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.
+
+fn f<T>() -> bool {
+    enum E<T> { V(T) }
+
+    struct S<T>(T);
+
+    true
+}
+
+fn main() {
+    let b = f::<int>();
+    assert!(b);
+}
\ No newline at end of file