]> git.lizzy.rs Git - rust.git/commitdiff
Update tests to show diagnostics
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 13 Dec 2018 11:54:49 +0000 (12:54 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 13 Dec 2018 11:54:49 +0000 (12:54 +0100)
src/test/run-pass/ctfe/references.rs
src/test/ui/pattern/const-pat-ice.rs [new file with mode: 0644]
src/test/ui/pattern/slice-pattern-const-2.rs
src/test/ui/pattern/slice-pattern-const-2.stderr [new file with mode: 0644]
src/test/ui/pattern/slice-pattern-const-3.rs
src/test/ui/pattern/slice-pattern-const-3.stderr [new file with mode: 0644]
src/test/ui/pattern/slice-pattern-const.rs
src/test/ui/pattern/slice-pattern-const.stderr [new file with mode: 0644]

index d5ab8dd7a2aac86f035036f55dcd8be67702cea8..421f35438302b6d1d927405a9fd1c1242b14d8ae 100644 (file)
@@ -31,7 +31,7 @@ fn main() {
     #[allow(unreachable_patterns)]
     match &43 {
         &42 => panic!(),
-        BOO => panic!(), // pattern is unreachable
+        BOO => panic!(),
         _ => println!("d"),
     }
 }
diff --git a/src/test/ui/pattern/const-pat-ice.rs b/src/test/ui/pattern/const-pat-ice.rs
new file mode 100644 (file)
index 0000000..6496a2a
--- /dev/null
@@ -0,0 +1,13 @@
+// failure-status: 101
+
+// This is a repro test for an ICE in our pattern handling of constants.
+
+const FOO: &&&u32 = &&&42;
+
+fn main() {
+    match unimplemented!() {
+        &&&42 => {},
+        FOO => {},
+        _ => {},
+    }
+}
index 15c23b39b01f2cdb205b439d68e498df61a63cf8..6cfef115d08dc0fc0697211e4d56d45e3b92c253 100644 (file)
@@ -1,4 +1,4 @@
-// compile-pass
+#![deny(unreachable_patterns)]
 
 fn main() {
     let s = &[0x00; 4][..]; //Slice of any value
@@ -6,26 +6,26 @@ fn main() {
     match s {
         MAGIC_TEST => (),
         [0x00, 0x00, 0x00, 0x00] => (),
-        [4, 5, 6, 7] => (), // this should warn
+        [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
         _ => (),
     }
     match s {
         [0x00, 0x00, 0x00, 0x00] => (),
         MAGIC_TEST => (),
-        [4, 5, 6, 7] => (), // this should warn
+        [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
         _ => (),
     }
     match s {
         [0x00, 0x00, 0x00, 0x00] => (),
         [4, 5, 6, 7] => (),
-        MAGIC_TEST => (), // this should warn
+        MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
         _ => (),
     }
     const FOO: [u32; 1] = [4];
     match [99] {
         [0x00] => (),
         [4] => (),
-        FOO => (), // this should warn
+        FOO => (), //~ ERROR unreachable pattern
         _ => (),
     }
 }
diff --git a/src/test/ui/pattern/slice-pattern-const-2.stderr b/src/test/ui/pattern/slice-pattern-const-2.stderr
new file mode 100644 (file)
index 0000000..95651cc
--- /dev/null
@@ -0,0 +1,26 @@
+error: unreachable pattern
+  --> $DIR/slice-pattern-const-2.rs:9:9
+   |
+LL |         [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
+   |         ^^^^^^^^^^^^
+   |
+note: lint level defined here
+  --> $DIR/slice-pattern-const-2.rs:1:9
+   |
+LL | #![deny(unreachable_patterns)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const-2.rs:15:9
+   |
+LL |         [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
+   |         ^^^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const-2.rs:28:9
+   |
+LL |         FOO => (), //~ ERROR unreachable pattern
+   |         ^^^
+
+error: aborting due to 3 previous errors
+
index dbc61af16b56059aa9d6b39311142df4cff7dca6..8805c43ba0283bdabe7f46093ee46b6be341470b 100644 (file)
@@ -1,4 +1,4 @@
-// compile-pass
+#![deny(unreachable_patterns)]
 
 fn main() {
     let s = &["0x00"; 4][..]; //Slice of any value
@@ -6,26 +6,26 @@ fn main() {
     match s {
         MAGIC_TEST => (),
         ["0x00", "0x00", "0x00", "0x00"] => (),
-        ["4", "5", "6", "7"] => (), // this should warn
+        ["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
         _ => (),
     }
     match s {
         ["0x00", "0x00", "0x00", "0x00"] => (),
         MAGIC_TEST => (),
-        ["4", "5", "6", "7"] => (), // this should warn
+        ["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
         _ => (),
     }
     match s {
         ["0x00", "0x00", "0x00", "0x00"] => (),
         ["4", "5", "6", "7"] => (),
-        MAGIC_TEST => (), // this should warn
+        MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
         _ => (),
     }
     const FOO: [&str; 1] = ["boo"];
     match ["baa"] {
         ["0x00"] => (),
         ["boo"] => (),
-        FOO => (), // this should warn
+        FOO => (), //~ ERROR unreachable pattern
         _ => (),
     }
 }
diff --git a/src/test/ui/pattern/slice-pattern-const-3.stderr b/src/test/ui/pattern/slice-pattern-const-3.stderr
new file mode 100644 (file)
index 0000000..531bbbc
--- /dev/null
@@ -0,0 +1,14 @@
+error: unreachable pattern
+  --> $DIR/slice-pattern-const-3.rs:28:9
+   |
+LL |         FOO => (), //~ ERROR unreachable pattern
+   |         ^^^
+   |
+note: lint level defined here
+  --> $DIR/slice-pattern-const-3.rs:1:9
+   |
+LL | #![deny(unreachable_patterns)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
index e2589ddf81c64a74a39ce7781108037277218e17..f0a04513f91fb71d11cc68154225df0c0ed10176 100644 (file)
@@ -1,4 +1,4 @@
-//compile-pass
+#![deny(unreachable_patterns)]
 
 fn main() {
     let s = &[0x00; 4][..]; //Slice of any value
@@ -6,33 +6,33 @@ fn main() {
     match s {
         MAGIC_TEST => (),
         [0x00, 0x00, 0x00, 0x00] => (),
-        [84, 69, 83, 84] => (), // this should warn
+        [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
         _ => (),
     }
     match s {
         [0x00, 0x00, 0x00, 0x00] => (),
         MAGIC_TEST => (),
-        [84, 69, 83, 84] => (), // this should warn
+        [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
         _ => (),
     }
     match s {
         [0x00, 0x00, 0x00, 0x00] => (),
         [84, 69, 83, 84] => (),
-        MAGIC_TEST => (), // this should warn
+        MAGIC_TEST => (), //~ ERROR unreachable pattern
         _ => (),
     }
     const FOO: [u8; 1] = [4];
     match [99] {
         [0x00] => (),
         [4] => (),
-        FOO => (), // this should warn
+        FOO => (), //~ ERROR unreachable pattern
         _ => (),
     }
     const BAR: &[u8; 1] = &[4];
     match &[99] {
         [0x00] => (),
         [4] => (),
-        BAR => (), // this should warn
+        BAR => (), //~ ERROR unreachable pattern
         b"a" => (),
         _ => (),
     }
@@ -40,8 +40,8 @@ fn main() {
     const BOO: &[u8; 0] = &[];
     match &[] {
         [] => (),
-        BOO => (), // this should warn
-        b"" => (),
-        _ => (),
+        BOO => (), //~ ERROR unreachable pattern
+        b"" => (), //~ ERROR unreachable pattern
+        _ => (), //~ ERROR unreachable pattern
     }
 }
diff --git a/src/test/ui/pattern/slice-pattern-const.stderr b/src/test/ui/pattern/slice-pattern-const.stderr
new file mode 100644 (file)
index 0000000..412e015
--- /dev/null
@@ -0,0 +1,56 @@
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:9:9
+   |
+LL |         [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
+   |         ^^^^^^^^^^^^^^^^
+   |
+note: lint level defined here
+  --> $DIR/slice-pattern-const.rs:1:9
+   |
+LL | #![deny(unreachable_patterns)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:15:9
+   |
+LL |         [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
+   |         ^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:21:9
+   |
+LL |         MAGIC_TEST => (), //~ ERROR unreachable pattern
+   |         ^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:28:9
+   |
+LL |         FOO => (), //~ ERROR unreachable pattern
+   |         ^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:35:9
+   |
+LL |         BAR => (), //~ ERROR unreachable pattern
+   |         ^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:43:9
+   |
+LL |         BOO => (), //~ ERROR unreachable pattern
+   |         ^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:44:9
+   |
+LL |         b"" => (), //~ ERROR unreachable pattern
+   |         ^^^
+
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:45:9
+   |
+LL |         _ => (), //~ ERROR unreachable pattern
+   |         ^
+
+error: aborting due to 8 previous errors
+