about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2019-06-12 08:46:56 +0100
committerDavid Wood <david@davidtw.co>2019-07-07 20:23:28 +0100
commita655438988c5f7d100a5423752b7ae0287d582fd (patch)
tree1f72516322ce74aa3e37b0302aabbfc4596d8153 /src
parent813c994a754b963660b2030699ee1b77c5886ed5 (diff)
downloadrust-a655438988c5f7d100a5423752b7ae0287d582fd.tar.gz
rust-a655438988c5f7d100a5423752b7ae0287d582fd.zip
tests: Update and add tests for RFC 2203.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs26
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr (renamed from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.stderr)4
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs (renamed from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.rs)17
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs25
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr (renamed from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.stderr)4
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs (renamed from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.rs)17
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs12
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs10
-rw-r--r--src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr13
9 files changed, 96 insertions, 32 deletions
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs
new file mode 100644
index 00000000000..3b7d7e5b51a
--- /dev/null
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs
@@ -0,0 +1,26 @@
+// ignore-tidy-linelength
+// ignore-compare-mode-nll
+// compile-flags: -Z borrowck=migrate
+#![feature(const_in_array_repeat_expressions)]
+#![allow(warnings)]
+
+// Some type that is not copyable.
+struct Bar;
+
+mod non_constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_multiple_elements() {
+        let x = None;
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
+    }
+
+    fn no_impl_copy_value_multiple_elements() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr
index 0b2da5933a1..aad6763f150 100644
--- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.stderr
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
-  --> $DIR/nll-borrowck.rs:87:37
+  --> $DIR/migrate-fail.rs:15:37
    |
 LL |         let arr: [Option<Bar>; 2] = [x; 2];
    |                                     ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
@@ -9,7 +9,7 @@ LL |         let arr: [Option<Bar>; 2] = [x; 2];
    = note: the `Copy` trait is required because the repeated element will be copied
 
 error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
-  --> $DIR/nll-borrowck.rs:103:37
+  --> $DIR/migrate-fail.rs:21:37
    |
 LL |         let arr: [Option<Bar>; 2] = [x; 2];
    |                                     ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs
index 5e7f11799c8..bfa8ebcfdd3 100644
--- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.rs
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs
@@ -1,6 +1,7 @@
-// ignore-compile-mode-nll
+// check-pass
 // compile-flags: -Z borrowck=migrate
-#![feature(constants_in_array_repeat_expressions)]
+// ignore-compare-mode-nll
+#![feature(const_in_array_repeat_expressions)]
 #![allow(warnings)]
 
 // Some type that is not copyable.
@@ -83,12 +84,6 @@ mod non_constants {
         let arr: [Option<Bar>; 1] = [x; 1];
     }
 
-    fn no_impl_copy_empty_value_multiple_elements() {
-        let x = None;
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
-    }
-
     fn no_impl_copy_value_no_elements() {
         let x = Some(Bar);
         let arr: [Option<Bar>; 0] = [x; 0];
@@ -99,12 +94,6 @@ mod non_constants {
         let arr: [Option<Bar>; 1] = [x; 1];
     }
 
-    fn no_impl_copy_value_multiple_elements() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
-    }
-
     fn impl_copy_empty_value_no_elements() {
         let x: Option<u32> = None;
         let arr: [Option<u32>; 0] = [x; 0];
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs
new file mode 100644
index 00000000000..dc1193a2fe8
--- /dev/null
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs
@@ -0,0 +1,25 @@
+// ignore-tidy-linelength
+// ignore-compare-mode-nll
+#![feature(const_in_array_repeat_expressions, nll)]
+#![allow(warnings)]
+
+// Some type that is not copyable.
+struct Bar;
+
+mod non_constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_multiple_elements() {
+        let x = None;
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
+    }
+
+    fn no_impl_copy_value_multiple_elements() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr
index 71f5a8ccaa2..fd32484ff92 100644
--- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.stderr
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
-  --> $DIR/migrate-borrowck.rs:88:37
+  --> $DIR/nll-fail.rs:14:37
    |
 LL |         let arr: [Option<Bar>; 2] = [x; 2];
    |                                     ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
@@ -9,7 +9,7 @@ LL |         let arr: [Option<Bar>; 2] = [x; 2];
    = note: the `Copy` trait is required because the repeated element will be copied
 
 error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
-  --> $DIR/migrate-borrowck.rs:104:37
+  --> $DIR/nll-fail.rs:20:37
    |
 LL |         let arr: [Option<Bar>; 2] = [x; 2];
    |                                     ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs
index 804aa6b7c6d..a304f877ab7 100644
--- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.rs
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs
@@ -1,6 +1,7 @@
-// ignore-compile-mode-nll
+// check-pass
+// ignore-compare-mode-nll
 #![allow(warnings)]
-#![feature(constants_in_array_repeat_expressions, nll)]
+#![feature(const_in_array_repeat_expressions, nll)]
 
 // Some type that is not copyable.
 struct Bar;
@@ -82,12 +83,6 @@ mod non_constants {
         let arr: [Option<Bar>; 1] = [x; 1];
     }
 
-    fn no_impl_copy_empty_value_multiple_elements() {
-        let x = None;
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
-    }
-
     fn no_impl_copy_value_no_elements() {
         let x = Some(Bar);
         let arr: [Option<Bar>; 0] = [x; 0];
@@ -98,12 +93,6 @@ mod non_constants {
         let arr: [Option<Bar>; 1] = [x; 1];
     }
 
-    fn no_impl_copy_value_multiple_elements() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
-    }
-
     fn impl_copy_empty_value_no_elements() {
         let x: Option<u32> = None;
         let arr: [Option<u32>; 0] = [x; 0];
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs
new file mode 100644
index 00000000000..27bf5dabf56
--- /dev/null
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs
@@ -0,0 +1,12 @@
+// run-pass
+#![feature(const_in_array_repeat_expressions)]
+
+#[derive(Debug, Eq, PartialEq)]
+struct Bar;
+
+fn main() {
+    const FOO: Option<Bar> = None;
+    const ARR: [Option<Bar>; 2] = [FOO; 2];
+
+    assert_eq!(ARR, [None::<Bar>, None::<Bar>]);
+}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs
new file mode 100644
index 00000000000..35484d265bb
--- /dev/null
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs
@@ -0,0 +1,10 @@
+// ignore-tidy-linelength
+#![feature(const_in_array_repeat_expressions)]
+
+#[derive(Copy, Clone)]
+struct Foo<T>(T);
+
+fn main() {
+    [Foo(String::new()); 4];
+    //~^ ERROR the trait bound `Foo<std::string::String>: std::marker::Copy` is not satisfied [E0277]
+}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr
new file mode 100644
index 00000000000..186909e469e
--- /dev/null
+++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr
@@ -0,0 +1,13 @@
+error[E0277]: the trait bound `Foo<std::string::String>: std::marker::Copy` is not satisfied
+  --> $DIR/trait-error.rs:8:5
+   |
+LL |     [Foo(String::new()); 4];
+   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `Foo<std::string::String>`
+   |
+   = help: the following implementations were found:
+             <Foo<T> as std::marker::Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.