summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs')
-rw-r--r--tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs261
1 files changed, 75 insertions, 186 deletions
diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs
index 2a9a5472b..4ac3ea53a 100644
--- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs
+++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs
@@ -27,64 +27,46 @@ fn main() {}
fn _if() {
if (let 0 = 1) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if (((let 0 = 1))) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if (let 0 = 1) && true {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if true && (let 0 = 1) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if (let 0 = 1) && (let 0 = 1) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
}
fn _while() {
while (let 0 = 1) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while (((let 0 = 1))) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while (let 0 = 1) && true {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while true && (let 0 = 1) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while (let 0 = 1) && (let 0 = 1) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
}
@@ -97,32 +79,21 @@ fn _macros() {
}
}
use_expr!((let 0 = 1 && 0 == 0));
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
use_expr!((let 0 = 1));
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
fn nested_within_if_expr() {
if &let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if !let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if *let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR type `bool` cannot be dereferenced
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if -let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR cannot apply unary operator `-` to type `bool`
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
fn _check_try_binds_tighter() -> Result<(), ()> {
if let 0 = 0? {}
@@ -130,91 +101,63 @@ fn nested_within_if_expr() {
Ok(())
}
if (let 0 = 0)? {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR the `?` operator can only be applied to values that implement `Try`
- //~| ERROR the `?` operator can only be used in a function that returns `Result`
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if true || let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if (true || let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if true && (true || let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if true || (true && let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
let mut x = true;
if x = let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if true..(let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
if ..(let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
if (let 0 = 0).. {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
// Binds as `(let ... = true)..true &&/|| false`.
if let Range { start: _, end: _ } = true..true && false {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
if let Range { start: _, end: _ } = true..true || false {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
// Binds as `(let Range { start: F, end } = F)..(|| true)`.
const F: fn() -> bool = || true;
if let Range { start: F, end } = F..|| true {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
// Binds as `(let Range { start: true, end } = t)..(&&false)`.
let t = &&true;
if let Range { start: true, end } = t..&&false {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
if let true = let true = true {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
fn nested_within_while_expr() {
while &let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while !let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while *let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR type `bool` cannot be dereferenced
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while -let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR cannot apply unary operator `-` to type `bool`
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
fn _check_try_binds_tighter() -> Result<(), ()> {
while let 0 = 0? {}
@@ -222,72 +165,51 @@ fn nested_within_while_expr() {
Ok(())
}
while (let 0 = 0)? {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR the `?` operator can only be applied to values that implement `Try`
- //~| ERROR the `?` operator can only be used in a function that returns `Result`
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while true || let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while (true || let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while true && (true || let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while true || (true && let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
let mut x = true;
while x = let 0 = 0 {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while true..(let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
while ..(let 0 = 0) {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
while (let 0 = 0).. {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
// Binds as `(let ... = true)..true &&/|| false`.
while let Range { start: _, end: _ } = true..true && false {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
while let Range { start: _, end: _ } = true..true || false {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
// Binds as `(let Range { start: F, end } = F)..(|| true)`.
const F: fn() -> bool = || true;
while let Range { start: F, end } = F..|| true {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
// Binds as `(let Range { start: true, end } = t)..(&&false)`.
let t = &&true;
while let Range { start: true, end } = t..&&false {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR mismatched types
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR mismatched types
while let true = let true = true {}
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
fn not_error_because_clarified_intent() {
@@ -302,20 +224,14 @@ fn not_error_because_clarified_intent() {
fn outside_if_and_while_expr() {
&let 0 = 0;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
!let 0 = 0;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
*let 0 = 0;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR type `bool` cannot be dereferenced
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
-let 0 = 0;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR cannot apply unary operator `-` to type `bool`
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
fn _check_try_binds_tighter() -> Result<(), ()> {
let 0 = 0?;
@@ -323,44 +239,32 @@ fn outside_if_and_while_expr() {
Ok(())
}
(let 0 = 0)?;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR the `?` operator can only be used in a function that returns `Result`
- //~| ERROR the `?` operator can only be applied to values that implement `Try`
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
true || let 0 = 0;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
(true || let 0 = 0);
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
true && (true || let 0 = 0);
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
let mut x = true;
x = let 0 = 0;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
true..(let 0 = 0);
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
..(let 0 = 0);
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
(let 0 = 0)..;
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
(let Range { start: _, end: _ } = true..true || false);
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
+ //~^ ERROR mismatched types
//~| ERROR expected expression, found `let` statement
(let true = let true = true);
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
{
@@ -377,9 +281,7 @@ fn outside_if_and_while_expr() {
// Check function tail position.
&let 0 = 0
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR mismatched types
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
// Let's make sure that `let` inside const generic arguments are considered.
@@ -389,20 +291,17 @@ fn inside_const_generic_arguments() {
if let A::<{
true && let 1 = 1
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}>::O = 5 {}
while let A::<{
true && let 1 = 1
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}>::O = 5 {}
if A::<{
true && let 1 = 1
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}>::O == 5 {}
// In the cases above we have `ExprKind::Block` to help us out.
@@ -413,8 +312,7 @@ fn inside_const_generic_arguments() {
if A::<
true && let 1 = 1
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expressions must be enclosed in braces
+ //~^ ERROR expressions must be enclosed in braces
//~| ERROR expected expression, found `let` statement
>::O == 5 {}
}
@@ -423,38 +321,29 @@ fn with_parenthesis() {
let opt = Some(Some(1i32));
if (let Some(a) = opt && true) {
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
if (let Some(a) = opt) && true {
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
if (let Some(a) = opt) && (let Some(b) = a) {
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
}
if let Some(a) = opt && (true && true) {
}
if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
}
if (let Some(a) = opt && (let Some(b) = a)) && true {
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
}
if (let Some(a) = opt && (true)) && true {
- //~^ ERROR `let` expressions are not supported here
- //~| ERROR expected expression, found `let` statement
+ //~^ ERROR expected expression, found `let` statement
}
if (true && (true)) && let Some(a) = opt {