]> git.lizzy.rs Git - rust.git/commitdiff
Move src/test/ui/if-*.rs to src/test/expr/if/if-*.rs
authorHavvy (Ryan Scheel) <ryan.havvy@gmail.com>
Wed, 25 Nov 2020 01:53:39 +0000 (17:53 -0800)
committerHavvy (Ryan Scheel) <ryan.havvy@gmail.com>
Wed, 25 Nov 2020 01:53:39 +0000 (17:53 -0800)
12 files changed:
src/test/ui/expr/if-bot.rs [new file with mode: 0644]
src/test/ui/expr/if/if-check.rs [new file with mode: 0644]
src/test/ui/expr/if/if-else-type-mismatch.rs [new file with mode: 0644]
src/test/ui/expr/if/if-else-type-mismatch.stderr [new file with mode: 0644]
src/test/ui/expr/if/if-ret.rs [new file with mode: 0644]
src/test/ui/expr/if/if-ret.stderr [new file with mode: 0644]
src/test/ui/if-bot.rs [deleted file]
src/test/ui/if-check.rs [deleted file]
src/test/ui/if-else-type-mismatch.rs [deleted file]
src/test/ui/if-else-type-mismatch.stderr [deleted file]
src/test/ui/if-ret.rs [deleted file]
src/test/ui/if-ret.stderr [deleted file]

diff --git a/src/test/ui/expr/if-bot.rs b/src/test/ui/expr/if-bot.rs
new file mode 100644 (file)
index 0000000..0f09db5
--- /dev/null
@@ -0,0 +1,6 @@
+// run-pass
+
+pub fn main() {
+    let i: isize = if false { panic!() } else { 5 };
+    println!("{}", i);
+}
diff --git a/src/test/ui/expr/if/if-check.rs b/src/test/ui/expr/if/if-check.rs
new file mode 100644 (file)
index 0000000..6593225
--- /dev/null
@@ -0,0 +1,17 @@
+// run-pass
+
+fn even(x: usize) -> bool {
+    if x < 2 {
+        return false;
+    } else if x == 2 { return true; } else { return even(x - 2); }
+}
+
+fn foo(x: usize) {
+    if even(x) {
+        println!("{}", x);
+    } else {
+        panic!();
+    }
+}
+
+pub fn main() { foo(2); }
diff --git a/src/test/ui/expr/if/if-else-type-mismatch.rs b/src/test/ui/expr/if/if-else-type-mismatch.rs
new file mode 100644 (file)
index 0000000..1a0a36d
--- /dev/null
@@ -0,0 +1,46 @@
+fn main() {
+    let _ = if true {
+        1i32
+    } else {
+        2u32
+    };
+    //~^^ ERROR `if` and `else` have incompatible types
+    let _ = if true { 42i32 } else { 42u32 };
+    //~^ ERROR `if` and `else` have incompatible types
+    let _ = if true {
+        3u32;
+    } else {
+        4u32
+    };
+    //~^^ ERROR `if` and `else` have incompatible types
+    let _ = if true {
+        5u32
+    } else {
+        6u32;
+    };
+    //~^^ ERROR `if` and `else` have incompatible types
+    let _ = if true {
+        7i32;
+    } else {
+        8u32
+    };
+    //~^^ ERROR `if` and `else` have incompatible types
+    let _ = if true {
+        9i32
+    } else {
+        10u32;
+    };
+    //~^^ ERROR `if` and `else` have incompatible types
+    let _ = if true {
+
+    } else {
+        11u32
+    };
+    //~^^ ERROR `if` and `else` have incompatible types
+    let _ = if true {
+        12i32
+    } else {
+
+    };
+    //~^^^ ERROR `if` and `else` have incompatible types
+}
diff --git a/src/test/ui/expr/if/if-else-type-mismatch.stderr b/src/test/ui/expr/if/if-else-type-mismatch.stderr
new file mode 100644 (file)
index 0000000..9fa190d
--- /dev/null
@@ -0,0 +1,106 @@
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:5:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         1i32
+   | |         ---- expected because of this
+LL | |     } else {
+LL | |         2u32
+   | |         ^^^^ expected `i32`, found `u32`
+LL | |     };
+   | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:8:38
+   |
+LL |     let _ = if true { 42i32 } else { 42u32 };
+   |                       -----          ^^^^^ expected `i32`, found `u32`
+   |                       |
+   |                       expected because of this
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:13:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         3u32;
+   | |         -----
+   | |         |   |
+   | |         |   help: consider removing this semicolon
+   | |         expected because of this
+LL | |     } else {
+LL | |         4u32
+   | |         ^^^^ expected `()`, found `u32`
+LL | |     };
+   | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:19:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         5u32
+   | |         ---- expected because of this
+LL | |     } else {
+LL | |         6u32;
+   | |         ^^^^-
+   | |         |   |
+   | |         |   help: consider removing this semicolon
+   | |         expected `u32`, found `()`
+LL | |     };
+   | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:25:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         7i32;
+   | |         ----- expected because of this
+LL | |     } else {
+LL | |         8u32
+   | |         ^^^^ expected `()`, found `u32`
+LL | |     };
+   | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:31:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         9i32
+   | |         ---- expected because of this
+LL | |     } else {
+LL | |         10u32;
+   | |         ^^^^^^ expected `i32`, found `()`
+LL | |     };
+   | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:37:9
+   |
+LL |       let _ = if true {
+   |  _____________________-
+LL | |
+LL | |     } else {
+   | |_____- expected because of this
+LL |           11u32
+   |           ^^^^^ expected `()`, found `u32`
+
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:42:12
+   |
+LL |       let _ = if true {
+   |               ------- `if` and `else` have incompatible types
+LL |           12i32
+   |           ----- expected because of this
+LL |       } else {
+   |  ____________^
+LL | |
+LL | |     };
+   | |_____^ expected `i32`, found `()`
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/expr/if/if-ret.rs b/src/test/ui/expr/if/if-ret.rs
new file mode 100644 (file)
index 0000000..6bb0141
--- /dev/null
@@ -0,0 +1,8 @@
+// run-pass
+
+#![allow(unused_parens)]
+// pretty-expanded FIXME #23616
+
+fn foo() { if (return) { } } //~ WARNING unreachable block in `if` expression
+
+pub fn main() { foo(); }
diff --git a/src/test/ui/expr/if/if-ret.stderr b/src/test/ui/expr/if/if-ret.stderr
new file mode 100644 (file)
index 0000000..41bbd79
--- /dev/null
@@ -0,0 +1,12 @@
+warning: unreachable block in `if` expression
+  --> $DIR/if-ret.rs:6:24
+   |
+LL | fn foo() { if (return) { } }
+   |               -------- ^^^ unreachable block in `if` expression
+   |               |
+   |               any code following this expression is unreachable
+   |
+   = note: `#[warn(unreachable_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/if-bot.rs b/src/test/ui/if-bot.rs
deleted file mode 100644 (file)
index 0f09db5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// run-pass
-
-pub fn main() {
-    let i: isize = if false { panic!() } else { 5 };
-    println!("{}", i);
-}
diff --git a/src/test/ui/if-check.rs b/src/test/ui/if-check.rs
deleted file mode 100644 (file)
index 6593225..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// run-pass
-
-fn even(x: usize) -> bool {
-    if x < 2 {
-        return false;
-    } else if x == 2 { return true; } else { return even(x - 2); }
-}
-
-fn foo(x: usize) {
-    if even(x) {
-        println!("{}", x);
-    } else {
-        panic!();
-    }
-}
-
-pub fn main() { foo(2); }
diff --git a/src/test/ui/if-else-type-mismatch.rs b/src/test/ui/if-else-type-mismatch.rs
deleted file mode 100644 (file)
index 1a0a36d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-fn main() {
-    let _ = if true {
-        1i32
-    } else {
-        2u32
-    };
-    //~^^ ERROR `if` and `else` have incompatible types
-    let _ = if true { 42i32 } else { 42u32 };
-    //~^ ERROR `if` and `else` have incompatible types
-    let _ = if true {
-        3u32;
-    } else {
-        4u32
-    };
-    //~^^ ERROR `if` and `else` have incompatible types
-    let _ = if true {
-        5u32
-    } else {
-        6u32;
-    };
-    //~^^ ERROR `if` and `else` have incompatible types
-    let _ = if true {
-        7i32;
-    } else {
-        8u32
-    };
-    //~^^ ERROR `if` and `else` have incompatible types
-    let _ = if true {
-        9i32
-    } else {
-        10u32;
-    };
-    //~^^ ERROR `if` and `else` have incompatible types
-    let _ = if true {
-
-    } else {
-        11u32
-    };
-    //~^^ ERROR `if` and `else` have incompatible types
-    let _ = if true {
-        12i32
-    } else {
-
-    };
-    //~^^^ ERROR `if` and `else` have incompatible types
-}
diff --git a/src/test/ui/if-else-type-mismatch.stderr b/src/test/ui/if-else-type-mismatch.stderr
deleted file mode 100644 (file)
index 9fa190d..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:5:9
-   |
-LL |       let _ = if true {
-   |  _____________-
-LL | |         1i32
-   | |         ---- expected because of this
-LL | |     } else {
-LL | |         2u32
-   | |         ^^^^ expected `i32`, found `u32`
-LL | |     };
-   | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:8:38
-   |
-LL |     let _ = if true { 42i32 } else { 42u32 };
-   |                       -----          ^^^^^ expected `i32`, found `u32`
-   |                       |
-   |                       expected because of this
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:13:9
-   |
-LL |       let _ = if true {
-   |  _____________-
-LL | |         3u32;
-   | |         -----
-   | |         |   |
-   | |         |   help: consider removing this semicolon
-   | |         expected because of this
-LL | |     } else {
-LL | |         4u32
-   | |         ^^^^ expected `()`, found `u32`
-LL | |     };
-   | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:19:9
-   |
-LL |       let _ = if true {
-   |  _____________-
-LL | |         5u32
-   | |         ---- expected because of this
-LL | |     } else {
-LL | |         6u32;
-   | |         ^^^^-
-   | |         |   |
-   | |         |   help: consider removing this semicolon
-   | |         expected `u32`, found `()`
-LL | |     };
-   | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:25:9
-   |
-LL |       let _ = if true {
-   |  _____________-
-LL | |         7i32;
-   | |         ----- expected because of this
-LL | |     } else {
-LL | |         8u32
-   | |         ^^^^ expected `()`, found `u32`
-LL | |     };
-   | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:31:9
-   |
-LL |       let _ = if true {
-   |  _____________-
-LL | |         9i32
-   | |         ---- expected because of this
-LL | |     } else {
-LL | |         10u32;
-   | |         ^^^^^^ expected `i32`, found `()`
-LL | |     };
-   | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:37:9
-   |
-LL |       let _ = if true {
-   |  _____________________-
-LL | |
-LL | |     } else {
-   | |_____- expected because of this
-LL |           11u32
-   |           ^^^^^ expected `()`, found `u32`
-
-error[E0308]: `if` and `else` have incompatible types
-  --> $DIR/if-else-type-mismatch.rs:42:12
-   |
-LL |       let _ = if true {
-   |               ------- `if` and `else` have incompatible types
-LL |           12i32
-   |           ----- expected because of this
-LL |       } else {
-   |  ____________^
-LL | |
-LL | |     };
-   | |_____^ expected `i32`, found `()`
-
-error: aborting due to 8 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/if-ret.rs b/src/test/ui/if-ret.rs
deleted file mode 100644 (file)
index 6bb0141..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// run-pass
-
-#![allow(unused_parens)]
-// pretty-expanded FIXME #23616
-
-fn foo() { if (return) { } } //~ WARNING unreachable block in `if` expression
-
-pub fn main() { foo(); }
diff --git a/src/test/ui/if-ret.stderr b/src/test/ui/if-ret.stderr
deleted file mode 100644 (file)
index 41bbd79..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-warning: unreachable block in `if` expression
-  --> $DIR/if-ret.rs:6:24
-   |
-LL | fn foo() { if (return) { } }
-   |               -------- ^^^ unreachable block in `if` expression
-   |               |
-   |               any code following this expression is unreachable
-   |
-   = note: `#[warn(unreachable_code)]` on by default
-
-warning: 1 warning emitted
-