diff options
Diffstat (limited to 'src/test/ui/expr')
49 files changed, 0 insertions, 1330 deletions
diff --git a/src/test/ui/expr/compound-assignment/eval-order.rs b/src/test/ui/expr/compound-assignment/eval-order.rs deleted file mode 100644 index 658adae19..000000000 --- a/src/test/ui/expr/compound-assignment/eval-order.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Test evaluation order of operands of the compound assignment operators - -// run-pass - -use std::ops::AddAssign; - -enum Side { - Lhs, - Rhs, -} - -// In the following tests, we place our value into a wrapper type so that we -// can do an element access as the outer place expression. If we just had the -// block expression, it'd be a value expression and not compile. -struct Wrapper<T>(T); - -// Evaluation order for `a op= b` where typeof(a) and typeof(b) are primitives -// is first `b` then `a`. -fn primitive_compound() { - let mut side_order = vec![]; - let mut int = Wrapper(0); - - { - side_order.push(Side::Lhs); - int - }.0 += { - side_order.push(Side::Rhs); - 0 - }; - - assert!(matches!(side_order[..], [Side::Rhs, Side::Lhs])); -} - -// Evaluation order for `a op=b` otherwise is first `a` then `b`. -fn generic_compound<T: AddAssign<T> + Default>() { - let mut side_order = vec![]; - let mut add_assignable: Wrapper<T> = Wrapper(Default::default()); - - { - side_order.push(Side::Lhs); - add_assignable - }.0 += { - side_order.push(Side::Rhs); - Default::default() - }; - - assert!(matches!(side_order[..], [Side::Lhs, Side::Rhs])); -} - -fn custom_compound() { - struct Custom; - - impl AddAssign<()> for Custom { - fn add_assign(&mut self, _: ()) { - // this block purposely left blank - } - } - - let mut side_order = vec![]; - let mut custom = Wrapper(Custom); - - { - side_order.push(Side::Lhs); - custom - }.0 += { - side_order.push(Side::Rhs); - }; - - assert!(matches!(side_order[..], [Side::Lhs, Side::Rhs])); -} - -fn main() { - primitive_compound(); - generic_compound::<i32>(); - custom_compound(); -} diff --git a/src/test/ui/expr/if-bot.rs b/src/test/ui/expr/if-bot.rs deleted file mode 100644 index 0f09db530..000000000 --- a/src/test/ui/expr/if-bot.rs +++ /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/expr/if/attrs/bad-cfg.rs b/src/test/ui/expr/if/attrs/bad-cfg.rs deleted file mode 100644 index 3f84929a0..000000000 --- a/src/test/ui/expr/if/attrs/bad-cfg.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(stmt_expr_attributes)] - -fn main() { - let _ = #[cfg(FALSE)] if true {}; //~ ERROR removing an expression -} diff --git a/src/test/ui/expr/if/attrs/bad-cfg.stderr b/src/test/ui/expr/if/attrs/bad-cfg.stderr deleted file mode 100644 index 8a2890886..000000000 --- a/src/test/ui/expr/if/attrs/bad-cfg.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: removing an expression is not supported in this position - --> $DIR/bad-cfg.rs:4:13 - | -LL | let _ = #[cfg(FALSE)] if true {}; - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/expr/if/attrs/builtin-if-attr.rs b/src/test/ui/expr/if/attrs/builtin-if-attr.rs deleted file mode 100644 index 7e2906615..000000000 --- a/src/test/ui/expr/if/attrs/builtin-if-attr.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -fn main() { - #[allow(unused_variables)] - if true { - let a = 1; - } else if false { - let b = 1; - } else { - let c = 1; - } -} diff --git a/src/test/ui/expr/if/attrs/cfg-false-if-attr.rs b/src/test/ui/expr/if/attrs/cfg-false-if-attr.rs deleted file mode 100644 index 1f77a1bb3..000000000 --- a/src/test/ui/expr/if/attrs/cfg-false-if-attr.rs +++ /dev/null @@ -1,43 +0,0 @@ -// check-pass - -#[cfg(FALSE)] -fn simple_attr() { - #[attr] if true {} - #[allow_warnings] if true {} -} - -#[cfg(FALSE)] -fn if_else_chain() { - #[first_attr] if true { - } else if false { - } else { - } -} - -#[cfg(FALSE)] -fn if_let() { - #[attr] if let Some(_) = Some(true) {} -} - -fn bar() { - #[cfg(FALSE)] - if true { - let x: () = true; // Should not error due to the #[cfg(FALSE)] - } - - #[cfg_attr(not(unset_attr), cfg(FALSE))] - if true { - let a: () = true; // Should not error due to the applied #[cfg(FALSE)] - } -} - -macro_rules! custom_macro { - ($expr:expr) => {} -} - -custom_macro! { - #[attr] if true {} -} - - -fn main() {} diff --git a/src/test/ui/expr/if/attrs/else-attrs.rs b/src/test/ui/expr/if/attrs/else-attrs.rs deleted file mode 100644 index 85da7cf6b..000000000 --- a/src/test/ui/expr/if/attrs/else-attrs.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(FALSE)] -fn if_else_parse_error() { - if true { - } #[attr] else if false { //~ ERROR expected - } -} - -#[cfg(FALSE)] -fn else_attr_ifparse_error() { - if true { - } else #[attr] if false { //~ ERROR outer attributes are not allowed - } else { - } -} - -#[cfg(FALSE)] -fn else_parse_error() { - if true { - } else if false { - } #[attr] else { //~ ERROR expected - } -} - -fn main() { -} diff --git a/src/test/ui/expr/if/attrs/else-attrs.stderr b/src/test/ui/expr/if/attrs/else-attrs.stderr deleted file mode 100644 index 273337705..000000000 --- a/src/test/ui/expr/if/attrs/else-attrs.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: expected expression, found keyword `else` - --> $DIR/else-attrs.rs:4:15 - | -LL | } #[attr] else if false { - | ^^^^ expected expression - -error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/else-attrs.rs:11:12 - | -LL | } else #[attr] if false { - | _______----_^^^^^^^_- - | | | | - | | | help: remove the attributes - | | the branch belongs to this `else` -LL | | } else { -LL | | } - | |_____- the attributes are attached to this branch - -error: expected expression, found keyword `else` - --> $DIR/else-attrs.rs:20:15 - | -LL | } #[attr] else { - | ^^^^ expected expression - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/expr/if/attrs/gate-whole-expr.rs b/src/test/ui/expr/if/attrs/gate-whole-expr.rs deleted file mode 100644 index 63772d54b..000000000 --- a/src/test/ui/expr/if/attrs/gate-whole-expr.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass - -fn main() { - let x = 1; - - #[cfg(FALSE)] - if false { - x = 2; - } else if true { - x = 3; - } else { - x = 4; - } - assert_eq!(x, 1); -} diff --git a/src/test/ui/expr/if/attrs/let-chains-attr.rs b/src/test/ui/expr/if/attrs/let-chains-attr.rs deleted file mode 100644 index 2cd873114..000000000 --- a/src/test/ui/expr/if/attrs/let-chains-attr.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass - -#![feature(let_chains)] - -#[cfg(FALSE)] -fn foo() { - #[attr] - if let Some(_) = Some(true) && let Ok(_) = Ok(1) { - } else if let Some(false) = Some(true) { - } -} - -fn main() {} diff --git a/src/test/ui/expr/if/attrs/stmt-expr-gated.rs b/src/test/ui/expr/if/attrs/stmt-expr-gated.rs deleted file mode 100644 index 38599c8e6..000000000 --- a/src/test/ui/expr/if/attrs/stmt-expr-gated.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let _ = #[deny(warnings)] if true { //~ ERROR attributes on expressions - } else if false { - } else { - }; -} diff --git a/src/test/ui/expr/if/attrs/stmt-expr-gated.stderr b/src/test/ui/expr/if/attrs/stmt-expr-gated.stderr deleted file mode 100644 index 47dac39a9..000000000 --- a/src/test/ui/expr/if/attrs/stmt-expr-gated.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: attributes on expressions are experimental - --> $DIR/stmt-expr-gated.rs:2:13 - | -LL | let _ = #[deny(warnings)] if true { - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/expr/if/bad-if-let-suggestion.rs b/src/test/ui/expr/if/bad-if-let-suggestion.rs deleted file mode 100644 index a8b2a2830..000000000 --- a/src/test/ui/expr/if/bad-if-let-suggestion.rs +++ /dev/null @@ -1,24 +0,0 @@ -// FIXME(compiler-errors): This really should suggest `let` on the RHS of the -// `&&` operator, but that's kinda hard to do because of precedence. -// Instead, for now we just make sure not to suggest `if let let`. -fn a() { - if let x = 1 && i = 2 {} - //~^ ERROR cannot find value `i` in this scope - //~| ERROR `let` expressions in this position are unstable - //~| ERROR mismatched types - //~| ERROR `let` expressions are not supported here -} - -fn b() { - if (i + j) = i {} - //~^ ERROR cannot find value `i` in this scope - //~| ERROR cannot find value `i` in this scope - //~| ERROR cannot find value `j` in this scope -} - -fn c() { - if x[0] = 1 {} - //~^ ERROR cannot find value `x` in this scope -} - -fn main() {} diff --git a/src/test/ui/expr/if/bad-if-let-suggestion.stderr b/src/test/ui/expr/if/bad-if-let-suggestion.stderr deleted file mode 100644 index 3a53a20b4..000000000 --- a/src/test/ui/expr/if/bad-if-let-suggestion.stderr +++ /dev/null @@ -1,74 +0,0 @@ -error: `let` expressions are not supported here - --> $DIR/bad-if-let-suggestion.rs:5:8 - | -LL | if let x = 1 && i = 2 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error[E0425]: cannot find value `i` in this scope - --> $DIR/bad-if-let-suggestion.rs:5:21 - | -LL | if let x = 1 && i = 2 {} - | ^ not found in this scope - -error[E0425]: cannot find value `i` in this scope - --> $DIR/bad-if-let-suggestion.rs:13:9 - | -LL | fn a() { - | ------ similarly named function `a` defined here -... -LL | if (i + j) = i {} - | ^ help: a function with a similar name exists: `a` - -error[E0425]: cannot find value `j` in this scope - --> $DIR/bad-if-let-suggestion.rs:13:13 - | -LL | fn a() { - | ------ similarly named function `a` defined here -... -LL | if (i + j) = i {} - | ^ help: a function with a similar name exists: `a` - -error[E0425]: cannot find value `i` in this scope - --> $DIR/bad-if-let-suggestion.rs:13:18 - | -LL | fn a() { - | ------ similarly named function `a` defined here -... -LL | if (i + j) = i {} - | ^ help: a function with a similar name exists: `a` - -error[E0425]: cannot find value `x` in this scope - --> $DIR/bad-if-let-suggestion.rs:20:8 - | -LL | fn a() { - | ------ similarly named function `a` defined here -... -LL | if x[0] = 1 {} - | ^ help: a function with a similar name exists: `a` - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/bad-if-let-suggestion.rs:5:8 - | -LL | if let x = 1 && i = 2 {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0308]: mismatched types - --> $DIR/bad-if-let-suggestion.rs:5:8 - | -LL | if let x = 1 && i = 2 {} - | ^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` - | -help: you might have meant to compare for equality - | -LL | if let x = 1 && i == 2 {} - | + - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0308, E0425, E0658. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/expr/if/expr-if-panic-fn.rs b/src/test/ui/expr/if/expr-if-panic-fn.rs deleted file mode 100644 index 36e49785a..000000000 --- a/src/test/ui/expr/if/expr-if-panic-fn.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-fail -// error-pattern:explicit panic -// ignore-emscripten no processes - -fn f() -> ! { - panic!() -} - -fn g() -> isize { - let x = if true { - f() - } else { - 10 - }; - return x; -} - -fn main() { - g(); -} diff --git a/src/test/ui/expr/if/expr-if-panic-pass.rs b/src/test/ui/expr/if/expr-if-panic-pass.rs deleted file mode 100644 index 6069cd835..000000000 --- a/src/test/ui/expr/if/expr-if-panic-pass.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - -fn test_if_panic() { - let x = if false { panic!() } else { 10 }; - assert_eq!(x, 10); -} - -fn test_else_panic() { - let x = if true { 10 } else { panic!() }; - assert_eq!(x, 10); -} - -fn test_elseif_panic() { - let x = if false { 0 } else if false { panic!() } else { 10 }; - assert_eq!(x, 10); -} - -pub fn main() { test_if_panic(); test_else_panic(); test_elseif_panic(); } diff --git a/src/test/ui/expr/if/expr-if-panic.rs b/src/test/ui/expr/if/expr-if-panic.rs deleted file mode 100644 index 520ee0870..000000000 --- a/src/test/ui/expr/if/expr-if-panic.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-fail -// error-pattern:explicit panic -// ignore-emscripten no processes - -fn main() { - let _x = if false { - 0 - } else if true { - panic!() - } else { - 10 - }; -} diff --git a/src/test/ui/expr/if/expr-if.rs b/src/test/ui/expr/if/expr-if.rs deleted file mode 100644 index 2b8474ff4..000000000 --- a/src/test/ui/expr/if/expr-if.rs +++ /dev/null @@ -1,52 +0,0 @@ -// run-pass -// Tests for if as expressions - -fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); } - -fn test_else() { - let rs: bool = if false { false } else { true }; - assert!((rs)); -} - -fn test_elseif1() { - let rs: bool = if true { true } else if true { false } else { false }; - assert!((rs)); -} - -fn test_elseif2() { - let rs: bool = if false { false } else if true { true } else { false }; - assert!((rs)); -} - -fn test_elseif3() { - let rs: bool = if false { false } else if false { false } else { true }; - assert!((rs)); -} - -fn test_inferrence() { - let rs = if true { true } else { false }; - assert!((rs)); -} - -fn test_if_as_if_condition() { - let rs1 = if if false { false } else { true } { true } else { false }; - assert!((rs1)); - let rs2 = if if true { false } else { true } { false } else { true }; - assert!((rs2)); -} - -fn test_if_as_block_result() { - let rs = if true { if false { false } else { true } } else { false }; - assert!((rs)); -} - -pub fn main() { - test_if(); - test_else(); - test_elseif1(); - test_elseif2(); - test_elseif3(); - test_inferrence(); - test_if_as_if_condition(); - test_if_as_block_result(); -} diff --git a/src/test/ui/expr/if/if-branch-types.rs b/src/test/ui/expr/if/if-branch-types.rs deleted file mode 100644 index c125ba306..000000000 --- a/src/test/ui/expr/if/if-branch-types.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let x = if true { 10i32 } else { 10u32 }; - //~^ ERROR `if` and `else` have incompatible types - //~| expected `i32`, found `u32` -} diff --git a/src/test/ui/expr/if/if-branch-types.stderr b/src/test/ui/expr/if/if-branch-types.stderr deleted file mode 100644 index d2bba8821..000000000 --- a/src/test/ui/expr/if/if-branch-types.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/if-branch-types.rs:2:38 - | -LL | let x = if true { 10i32 } else { 10u32 }; - | ----- ^^^^^ expected `i32`, found `u32` - | | - | expected because of this - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL | let x = if true { 10i32 } else { 10i32 }; - | ~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/expr/if/if-check-panic.rs b/src/test/ui/expr/if/if-check-panic.rs deleted file mode 100644 index 037cd427c..000000000 --- a/src/test/ui/expr/if/if-check-panic.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-fail -// error-pattern:Number is odd -// ignore-emscripten no processes - -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!("Number is odd"); - } -} - -fn main() { - foo(3); -} diff --git a/src/test/ui/expr/if/if-check.rs b/src/test/ui/expr/if/if-check.rs deleted file mode 100644 index 6593225e7..000000000 --- a/src/test/ui/expr/if/if-check.rs +++ /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/expr/if/if-cond-bot.rs b/src/test/ui/expr/if/if-cond-bot.rs deleted file mode 100644 index bcd114678..000000000 --- a/src/test/ui/expr/if/if-cond-bot.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-fail -// error-pattern:quux -// ignore-emscripten no processes - -fn my_err(s: String) -> ! { - println!("{}", s); - panic!("quux"); -} - -fn main() { - if my_err("bye".to_string()) { - } -} diff --git a/src/test/ui/expr/if/if-else-type-mismatch.rs b/src/test/ui/expr/if/if-else-type-mismatch.rs deleted file mode 100644 index 1a0a36df2..000000000 --- a/src/test/ui/expr/if/if-else-type-mismatch.rs +++ /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/expr/if/if-else-type-mismatch.stderr b/src/test/ui/expr/if/if-else-type-mismatch.stderr deleted file mode 100644 index f1fffdb1e..000000000 --- a/src/test/ui/expr/if/if-else-type-mismatch.stderr +++ /dev/null @@ -1,116 +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 - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL | 2i32 - | ~~~ - -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 - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL | let _ = if true { 42i32 } else { 42i32 }; - | ~~~ - -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-let-arm-types.rs b/src/test/ui/expr/if/if-let-arm-types.rs deleted file mode 100644 index 1e8260a01..000000000 --- a/src/test/ui/expr/if/if-let-arm-types.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn main() { - if let Some(b) = None { - //~^ NOTE `if` and `else` have incompatible types - () - //~^ NOTE expected because of this - } else { - 1 - }; - //~^^ ERROR: `if` and `else` have incompatible types - //~| NOTE expected `()`, found integer -} diff --git a/src/test/ui/expr/if/if-let-arm-types.stderr b/src/test/ui/expr/if/if-let-arm-types.stderr deleted file mode 100644 index b40a0f479..000000000 --- a/src/test/ui/expr/if/if-let-arm-types.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/if-let-arm-types.rs:7:9 - | -LL | / if let Some(b) = None { -LL | | -LL | | () - | | -- expected because of this -LL | | -LL | | } else { -LL | | 1 - | | ^ expected `()`, found integer -LL | | }; - | |_____- `if` and `else` have incompatible types - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/expr/if/if-let.rs b/src/test/ui/expr/if/if-let.rs deleted file mode 100644 index 7fdd2be95..000000000 --- a/src/test/ui/expr/if/if-let.rs +++ /dev/null @@ -1,49 +0,0 @@ -// check-pass - -fn macros() { - macro_rules! foo { - ($p:pat, $e:expr, $b:block) => {{ - if let $p = $e $b - //~^ WARN irrefutable `if let` - //~| WARN irrefutable `if let` - }} - } - macro_rules! bar{ - ($p:pat, $e:expr, $b:block) => {{ - foo!($p, $e, $b) - }} - } - - foo!(a, 1, { - println!("irrefutable pattern"); - }); - bar!(a, 1, { - println!("irrefutable pattern"); - }); -} - -pub fn main() { - if let a = 1 { //~ WARN irrefutable `if let` - println!("irrefutable pattern"); - } - - if let a = 1 { //~ WARN irrefutable `if let` - println!("irrefutable pattern"); - } else if true { - println!("else-if in irrefutable `if let`"); - } else { - println!("else in irrefutable `if let`"); - } - - if let 1 = 2 { - println!("refutable pattern"); - } else if let a = 1 { //~ WARN irrefutable `if let` - println!("irrefutable pattern"); - } - - if true { - println!("if"); - } else if let a = 1 { //~ WARN irrefutable `if let` - println!("irrefutable pattern"); - } -} diff --git a/src/test/ui/expr/if/if-let.stderr b/src/test/ui/expr/if/if-let.stderr deleted file mode 100644 index c4bba3cb1..000000000 --- a/src/test/ui/expr/if/if-let.stderr +++ /dev/null @@ -1,69 +0,0 @@ -warning: irrefutable `if let` pattern - --> $DIR/if-let.rs:6:16 - | -LL | if let $p = $e $b - | ^^^ -... -LL | / foo!(a, 1, { -LL | | println!("irrefutable pattern"); -LL | | }); - | |______- in this macro invocation - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - = note: `#[warn(irrefutable_let_patterns)]` on by default - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: irrefutable `if let` pattern - --> $DIR/if-let.rs:6:16 - | -LL | if let $p = $e $b - | ^^^ -... -LL | / bar!(a, 1, { -LL | | println!("irrefutable pattern"); -LL | | }); - | |______- in this macro invocation - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - = note: this warning originates in the macro `foo` which comes from the expansion of the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: irrefutable `if let` pattern - --> $DIR/if-let.rs:26:8 - | -LL | if let a = 1 { - | ^^^^^^^^^ - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - -warning: irrefutable `if let` pattern - --> $DIR/if-let.rs:30:8 - | -LL | if let a = 1 { - | ^^^^^^^^^ - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - -warning: irrefutable `if let` pattern - --> $DIR/if-let.rs:40:15 - | -LL | } else if let a = 1 { - | ^^^^^^^^^ - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - -warning: irrefutable `if let` pattern - --> $DIR/if-let.rs:46:15 - | -LL | } else if let a = 1 { - | ^^^^^^^^^ - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - -warning: 6 warnings emitted - diff --git a/src/test/ui/expr/if/if-loop.rs b/src/test/ui/expr/if/if-loop.rs deleted file mode 100644 index 06d0bdf45..000000000 --- a/src/test/ui/expr/if/if-loop.rs +++ /dev/null @@ -1,8 +0,0 @@ -// check-pass - -// This used to ICE because the "if" being unreachable was not handled correctly -fn err() { - if loop {} {} -} - -fn main() {} diff --git a/src/test/ui/expr/if/if-no-match-bindings.rs b/src/test/ui/expr/if/if-no-match-bindings.rs deleted file mode 100644 index ca3df0fdd..000000000 --- a/src/test/ui/expr/if/if-no-match-bindings.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Checks for `if` expressions with respect to default match bindings. -// Specifically, we do not accept `if cond { ... }` where `cond: &mut? bool`. -// Meanwhile, `match cond { true => ..., _ => ... }` does accept that. - -// FIXME(@rust-lang/lang-team): consider relaxing this? - -fn b_ref<'a>() -> &'a bool { &true } -fn b_mut_ref<'a>() -> &'a mut bool { &mut true } - -fn main() { - // This is OK: - match b_ref() { true => {}, _ => {} } - match b_mut_ref() { true => {}, _ => {} } - match &true { true => {}, _ => {} } - match &mut true { true => {}, _ => {} } - - // This is NOT: - if b_ref() {} //~ ERROR mismatched types [E0308] - if b_mut_ref() {} //~ ERROR mismatched types [E0308] - if &true {} //~ ERROR mismatched types [E0308] - if &mut true {} //~ ERROR mismatched types [E0308] - - // This is also NOT: - while b_ref() {} //~ ERROR mismatched types [E0308] - while b_mut_ref() {} //~ ERROR mismatched types [E0308] - while &true {} //~ ERROR mismatched types [E0308] - while &mut true {} //~ ERROR mismatched types [E0308] -} diff --git a/src/test/ui/expr/if/if-no-match-bindings.stderr b/src/test/ui/expr/if/if-no-match-bindings.stderr deleted file mode 100644 index 737a5d604..000000000 --- a/src/test/ui/expr/if/if-no-match-bindings.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:18:8 - | -LL | if b_ref() {} - | ^^^^^^^ expected `bool`, found `&bool` - | -help: consider dereferencing the borrow - | -LL | if *b_ref() {} - | + - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:19:8 - | -LL | if b_mut_ref() {} - | ^^^^^^^^^^^ expected `bool`, found `&mut bool` - | -help: consider dereferencing the borrow - | -LL | if *b_mut_ref() {} - | + - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:20:8 - | -LL | if &true {} - | ^^^^^ expected `bool`, found `&bool` - | -help: consider removing the borrow - | -LL - if &true {} -LL + if true {} - | - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:21:8 - | -LL | if &mut true {} - | ^^^^^^^^^ expected `bool`, found `&mut bool` - | -help: consider removing the borrow - | -LL - if &mut true {} -LL + if true {} - | - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:24:11 - | -LL | while b_ref() {} - | ^^^^^^^ expected `bool`, found `&bool` - | -help: consider dereferencing the borrow - | -LL | while *b_ref() {} - | + - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:25:11 - | -LL | while b_mut_ref() {} - | ^^^^^^^^^^^ expected `bool`, found `&mut bool` - | -help: consider dereferencing the borrow - | -LL | while *b_mut_ref() {} - | + - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:26:11 - | -LL | while &true {} - | ^^^^^ expected `bool`, found `&bool` - | -help: consider removing the borrow - | -LL - while &true {} -LL + while true {} - | - -error[E0308]: mismatched types - --> $DIR/if-no-match-bindings.rs:27:11 - | -LL | while &mut true {} - | ^^^^^^^^^ expected `bool`, found `&mut bool` - | -help: consider removing the borrow - | -LL - while &mut true {} -LL + while true {} - | - -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 deleted file mode 100644 index 896072ce7..000000000 --- a/src/test/ui/expr/if/if-ret.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass - -#![allow(unused_parens)] -// pretty-expanded FIXME #23616 - -fn foo() { if (return) { } } //~ WARNING unreachable block in `if` - -pub fn main() { foo(); } diff --git a/src/test/ui/expr/if/if-ret.stderr b/src/test/ui/expr/if/if-ret.stderr deleted file mode 100644 index 8ced271aa..000000000 --- a/src/test/ui/expr/if/if-ret.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: unreachable block in `if` or `while` expression - --> $DIR/if-ret.rs:6:24 - | -LL | fn foo() { if (return) { } } - | -------- ^^^ unreachable block in `if` or `while` 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/expr/if/if-typeck.rs b/src/test/ui/expr/if/if-typeck.rs deleted file mode 100644 index d8c262bd6..000000000 --- a/src/test/ui/expr/if/if-typeck.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:mismatched types -// issue #513 - -fn f() { } - -fn main() { - - // f is not a bool - if f { } -} diff --git a/src/test/ui/expr/if/if-typeck.stderr b/src/test/ui/expr/if/if-typeck.stderr deleted file mode 100644 index 74ed0ed0a..000000000 --- a/src/test/ui/expr/if/if-typeck.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/if-typeck.rs:9:8 - | -LL | if f { } - | ^ expected `bool`, found fn item - | - = note: expected type `bool` - found fn item `fn() {f}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/expr/if/if-without-block.rs b/src/test/ui/expr/if/if-without-block.rs deleted file mode 100644 index 5add9dfda..000000000 --- a/src/test/ui/expr/if/if-without-block.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - let n = 1; - if 5 == { - //~^ ERROR this `if` expression is missing a block after the condition - println!("five"); - } -} diff --git a/src/test/ui/expr/if/if-without-block.stderr b/src/test/ui/expr/if/if-without-block.stderr deleted file mode 100644 index 2d1ee04ce..000000000 --- a/src/test/ui/expr/if/if-without-block.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: this `if` expression is missing a block after the condition - --> $DIR/if-without-block.rs:3:5 - | -LL | if 5 == { - | ^^ - | -help: this binary operation is possibly unfinished - --> $DIR/if-without-block.rs:3:8 - | -LL | if 5 == { - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/expr/if/if-without-else-as-fn-expr.rs b/src/test/ui/expr/if/if-without-else-as-fn-expr.rs deleted file mode 100644 index 19fbfb27b..000000000 --- a/src/test/ui/expr/if/if-without-else-as-fn-expr.rs +++ /dev/null @@ -1,49 +0,0 @@ -fn foo(bar: usize) -> usize { - if bar % 5 == 0 { - return 3; - } - //~^^^ ERROR `if` may be missing an `else` clause -} - -fn foo2(bar: usize) -> usize { - let x: usize = if bar % 5 == 0 { - return 3; - }; - //~^^^ ERROR `if` may be missing an `else` clause - x -} - -fn foo3(bar: usize) -> usize { - if bar % 5 == 0 { - 3 - } - //~^^^ ERROR `if` may be missing an `else` clause -} - -fn foo_let(bar: usize) -> usize { - if let 0 = 1 { - return 3; - } - //~^^^ ERROR `if` may be missing an `else` clause -} - -fn foo2_let(bar: usize) -> usize { - let x: usize = if let 0 = 1 { - return 3; - }; - //~^^^ ERROR `if` may be missing an `else` clause - x -} - -fn foo3_let(bar: usize) -> usize { - if let 0 = 1 { - 3 - } - //~^^^ ERROR `if` may be missing an `else` clause -} - -// FIXME(60254): deduplicate first error in favor of second. - -fn main() { - let _ = foo(1); -} diff --git a/src/test/ui/expr/if/if-without-else-as-fn-expr.stderr b/src/test/ui/expr/if/if-without-else-as-fn-expr.stderr deleted file mode 100644 index 4daf27493..000000000 --- a/src/test/ui/expr/if/if-without-else-as-fn-expr.stderr +++ /dev/null @@ -1,83 +0,0 @@ -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-as-fn-expr.rs:2:5 - | -LL | fn foo(bar: usize) -> usize { - | ----- expected `usize` because of this return type -LL | / if bar % 5 == 0 { -LL | | return 3; -LL | | } - | |_____^ expected `usize`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-as-fn-expr.rs:9:20 - | -LL | let x: usize = if bar % 5 == 0 { - | _________-__________^ - | | | - | | expected because of this assignment -LL | | return 3; -LL | | }; - | |_____^ expected `usize`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-as-fn-expr.rs:17:5 - | -LL | fn foo3(bar: usize) -> usize { - | ----- expected `usize` because of this return type -LL | / if bar % 5 == 0 { -LL | | 3 -LL | | } - | |_____^ expected `usize`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-as-fn-expr.rs:24:5 - | -LL | fn foo_let(bar: usize) -> usize { - | ----- expected `usize` because of this return type -LL | / if let 0 = 1 { -LL | | return 3; -LL | | } - | |_____^ expected `usize`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-as-fn-expr.rs:31:20 - | -LL | let x: usize = if let 0 = 1 { - | _________-__________^ - | | | - | | expected because of this assignment -LL | | return 3; -LL | | }; - | |_____^ expected `usize`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-as-fn-expr.rs:39:5 - | -LL | fn foo3_let(bar: usize) -> usize { - | ----- expected `usize` because of this return type -LL | / if let 0 = 1 { -LL | | 3 -LL | | } - | |_____^ expected `usize`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/expr/if/if-without-else-result.rs b/src/test/ui/expr/if/if-without-else-result.rs deleted file mode 100644 index 95604758a..000000000 --- a/src/test/ui/expr/if/if-without-else-result.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let a = if true { true }; - //~^ ERROR `if` may be missing an `else` clause [E0317] - //~| expected `bool`, found `()` - println!("{}", a); -} diff --git a/src/test/ui/expr/if/if-without-else-result.stderr b/src/test/ui/expr/if/if-without-else-result.stderr deleted file mode 100644 index 317faf7c6..000000000 --- a/src/test/ui/expr/if/if-without-else-result.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-result.rs:2:13 - | -LL | let a = if true { true }; - | ^^^^^^^^^^----^^ - | | | - | | found here - | expected `bool`, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/expr/if/issue-4201.rs b/src/test/ui/expr/if/issue-4201.rs deleted file mode 100644 index 59c465b9e..000000000 --- a/src/test/ui/expr/if/issue-4201.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - let a = if true { - 0 - } else if false { -//~^ ERROR `if` may be missing an `else` clause -//~| expected integer, found `()` - 1 - }; -} diff --git a/src/test/ui/expr/if/issue-4201.stderr b/src/test/ui/expr/if/issue-4201.stderr deleted file mode 100644 index 612fe7764..000000000 --- a/src/test/ui/expr/if/issue-4201.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0317]: `if` may be missing an `else` clause - --> $DIR/issue-4201.rs:4:12 - | -LL | } else if false { - | ____________^ -LL | | -LL | | -LL | | 1 - | | - found here -LL | | }; - | |_____^ expected integer, found `()` - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/expr/malformed_closure/missing_braces_around_block.fixed b/src/test/ui/expr/malformed_closure/missing_braces_around_block.fixed deleted file mode 100644 index c50b9a12b..000000000 --- a/src/test/ui/expr/malformed_closure/missing_braces_around_block.fixed +++ /dev/null @@ -1,19 +0,0 @@ -// This snippet ensures that no attempt to recover on a semicolon instead of -// comma is made next to a closure body. -// -// If this recovery happens, then plenty of errors are emitted. Here, we expect -// only one error. -// -// This is part of issue #88065: -// https://github.com/rust-lang/rust/issues/88065 - -// run-rustfix - -fn main() { - let num = 5; - (1..num).reduce(|a, b| { - //~^ ERROR: closure bodies that contain statements must be surrounded by braces - println!("{}", a); - a * b - }).unwrap(); -} diff --git a/src/test/ui/expr/malformed_closure/missing_braces_around_block.rs b/src/test/ui/expr/malformed_closure/missing_braces_around_block.rs deleted file mode 100644 index 58c81f3a6..000000000 --- a/src/test/ui/expr/malformed_closure/missing_braces_around_block.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This snippet ensures that no attempt to recover on a semicolon instead of -// comma is made next to a closure body. -// -// If this recovery happens, then plenty of errors are emitted. Here, we expect -// only one error. -// -// This is part of issue #88065: -// https://github.com/rust-lang/rust/issues/88065 - -// run-rustfix - -fn main() { - let num = 5; - (1..num).reduce(|a, b| - //~^ ERROR: closure bodies that contain statements must be surrounded by braces - println!("{}", a); - a * b - ).unwrap(); -} diff --git a/src/test/ui/expr/malformed_closure/missing_braces_around_block.stderr b/src/test/ui/expr/malformed_closure/missing_braces_around_block.stderr deleted file mode 100644 index dac9a8cfc..000000000 --- a/src/test/ui/expr/malformed_closure/missing_braces_around_block.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: closure bodies that contain statements must be surrounded by braces - --> $DIR/missing_braces_around_block.rs:14:26 - | -LL | (1..num).reduce(|a, b| - | ^ -... -LL | ).unwrap(); - | ^ - | -note: statement found outside of a block - --> $DIR/missing_braces_around_block.rs:16:26 - | -LL | println!("{}", a); - | -----------------^ this `;` turns the preceding closure into a statement - | | - | this expression is a statement because of the trailing semicolon -note: the closure body may be incorrectly delimited - --> $DIR/missing_braces_around_block.rs:14:21 - | -LL | (1..num).reduce(|a, b| - | _____________________^ -LL | | -LL | | println!("{}", a); - | |_________________________^ this is the parsed closure... -LL | a * b -LL | ).unwrap(); - | - ...but likely you meant the closure to end here -help: try adding braces - | -LL ~ (1..num).reduce(|a, b| { -LL | -LL | println!("{}", a); -LL | a * b -LL ~ }).unwrap(); - | - -error: aborting due to previous error - diff --git a/src/test/ui/expr/malformed_closure/ruby_style_closure.rs b/src/test/ui/expr/malformed_closure/ruby_style_closure.rs deleted file mode 100644 index e4341e196..000000000 --- a/src/test/ui/expr/malformed_closure/ruby_style_closure.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Part of issue #27300. -// The problem here is that ruby-style closures are parsed as blocks whose -// first statement is a closure. See the issue for more details: -// https://github.com/rust-lang/rust/issues/27300 - -// Note: this test represents what the compiler currently emits. The error -// message will be improved later. - -fn main() { - let p = Some(45).and_then({ - //~^ expected a `FnOnce<({integer},)>` closure, found `Option<_>` - |x| println!("doubling {}", x); - Some(x * 2) - //~^ ERROR: cannot find value `x` in this scope - }); -} diff --git a/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr b/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr deleted file mode 100644 index 759d79493..000000000 --- a/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0425]: cannot find value `x` in this scope - --> $DIR/ruby_style_closure.rs:13:14 - | -LL | Some(x * 2) - | ^ not found in this scope - -error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` - --> $DIR/ruby_style_closure.rs:10:31 - | -LL | let p = Some(45).and_then({ - | ______________________--------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | |x| println!("doubling {}", x); -LL | | Some(x * 2) - | | ----------- this tail expression is of type `std::option::Option<_>` -LL | | -LL | | }); - | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` - | - = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` -note: required by a bound in `Option::<T>::and_then` - --> $SRC_DIR/core/src/option.rs:LL:COL - | -LL | F: ~const FnOnce(T) -> Option<U>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::and_then` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0425. -For more information about an error, try `rustc --explain E0277`. |