Unify disallowed-positions test files into one file
Also make the file have a third mode for where everything is cfg'd out to make sure it's an early error.
This commit is contained in:
parent
b73478b6ee
commit
7312b41239
@ -1,340 +0,0 @@
|
||||
// Check that we don't suggest enabling a feature for code that's
|
||||
// not accepted even with that feature.
|
||||
|
||||
#![allow(irrefutable_let_patterns)]
|
||||
|
||||
use std::ops::Range;
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn _if() {
|
||||
if (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if (((let 0 = 1))) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if (let 0 = 1) && true {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if true && (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if (let 0 = 1) && (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
|
||||
if (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
//~^ 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 expected expression, found `let` statement
|
||||
|
||||
while (((let 0 = 1))) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while (let 0 = 1) && true {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while true && (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while (let 0 = 1) && (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
|
||||
while (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
fn _macros() {
|
||||
macro_rules! use_expr {
|
||||
($e:expr) => {
|
||||
if $e {}
|
||||
while $e {}
|
||||
}
|
||||
}
|
||||
use_expr!((let 0 = 1 && 0 == 0));
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
use_expr!((let 0 = 1));
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
fn nested_within_if_expr() {
|
||||
if &let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if !let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if *let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if -let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
if let 0 = 0? {}
|
||||
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
Ok(())
|
||||
}
|
||||
if (let 0 = 0)? {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if true || let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if (true || let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if true && (true || let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if true || (true && let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
let mut x = true;
|
||||
if x = let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if true..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
if ..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if (let 0 = 0).. {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
// Binds as `(let ... = true)..true &&/|| false`.
|
||||
if let Range { start: _, end: _ } = true..true && false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
if let Range { start: _, end: _ } = true..true || false {}
|
||||
//~^ 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 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 expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
|
||||
if let true = let true = true {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
fn nested_within_while_expr() {
|
||||
while &let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while !let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while *let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while -let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
while let 0 = 0? {}
|
||||
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
Ok(())
|
||||
}
|
||||
while (let 0 = 0)? {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while true || let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while (true || let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while true && (true || let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while true || (true && let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
let mut x = true;
|
||||
while x = let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while true..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
while ..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while (let 0 = 0).. {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
// Binds as `(let ... = true)..true &&/|| false`.
|
||||
while let Range { start: _, end: _ } = true..true && false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
while let Range { start: _, end: _ } = true..true || false {}
|
||||
//~^ 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 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 expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
|
||||
while let true = let true = true {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
fn not_error_because_clarified_intent() {
|
||||
if let Range { start: _, end: _ } = (true..true || false) { }
|
||||
|
||||
if let Range { start: _, end: _ } = (true..true && false) { }
|
||||
|
||||
while let Range { start: _, end: _ } = (true..true || false) { }
|
||||
|
||||
while let Range { start: _, end: _ } = (true..true && false) { }
|
||||
}
|
||||
|
||||
fn outside_if_and_while_expr() {
|
||||
&let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
!let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
*let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
-let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
let _ = let _ = 3;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
let 0 = 0?;
|
||||
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
Ok(())
|
||||
}
|
||||
(let 0 = 0)?;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
true || let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
(true || let 0 = 0);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
true && (true || let 0 = 0);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
let mut x = true;
|
||||
x = let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
true..(let 0 = 0);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
..(let 0 = 0);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
(let 0 = 0)..;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
(let Range { start: _, end: _ } = true..true || false);
|
||||
//~^ ERROR mismatched types
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
|
||||
(let true = let true = true);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
|
||||
{
|
||||
#[cfg(FALSE)]
|
||||
let x = true && let y = 1;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
{
|
||||
[1, 2, 3][let _ = ()]
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
// Check function tail position.
|
||||
&let 0 = 0
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
// Let's make sure that `let` inside const generic arguments are considered.
|
||||
fn inside_const_generic_arguments() {
|
||||
struct A<const B: bool>;
|
||||
impl<const B: bool> A<{B}> { const O: u32 = 5; }
|
||||
|
||||
if let A::<{
|
||||
true && let 1 = 1
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}>::O = 5 {}
|
||||
|
||||
while let A::<{
|
||||
true && let 1 = 1
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}>::O = 5 {}
|
||||
|
||||
if A::<{
|
||||
true && let 1 = 1
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}>::O == 5 {}
|
||||
|
||||
// In the cases above we have `ExprKind::Block` to help us out.
|
||||
// Below however, we would not have a block and so an implementation might go
|
||||
// from visiting expressions to types without banning `let` expressions down the tree.
|
||||
// This tests ensures that we are not caught by surprise should the parser
|
||||
// admit non-IDENT expressions in const generic arguments.
|
||||
|
||||
if A::<
|
||||
true && let 1 = 1
|
||||
//~^ ERROR expressions must be enclosed in braces
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
>::O == 5 {}
|
||||
}
|
||||
|
||||
fn with_parenthesis() {
|
||||
let opt = Some(Some(1i32));
|
||||
|
||||
if (let Some(a) = opt && true) {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
if (let Some(a) = opt) && true {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
}
|
||||
if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
}
|
||||
if (let Some(a) = opt && (true)) && true {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
let x = (true && let y = 1);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
#[cfg(FALSE)]
|
||||
{
|
||||
([1, 2, 3][let _ = ()])
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,862 @@
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:32:9
|
||||
|
|
||||
LL | if (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:32:9
|
||||
|
|
||||
LL | if (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:35:11
|
||||
|
|
||||
LL | if (((let 0 = 1))) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:35:11
|
||||
|
|
||||
LL | if (((let 0 = 1))) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:38:9
|
||||
|
|
||||
LL | if (let 0 = 1) && true {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:38:9
|
||||
|
|
||||
LL | if (let 0 = 1) && true {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:41:17
|
||||
|
|
||||
LL | if true && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:41:17
|
||||
|
|
||||
LL | if true && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:44:9
|
||||
|
|
||||
LL | if (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:44:9
|
||||
|
|
||||
LL | if (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:44:24
|
||||
|
|
||||
LL | if (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:44:24
|
||||
|
|
||||
LL | if (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:48:35
|
||||
|
|
||||
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:48:35
|
||||
|
|
||||
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:48:48
|
||||
|
|
||||
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:48:35
|
||||
|
|
||||
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:48:61
|
||||
|
|
||||
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:48:35
|
||||
|
|
||||
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:58:12
|
||||
|
|
||||
LL | while (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:58:12
|
||||
|
|
||||
LL | while (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:61:14
|
||||
|
|
||||
LL | while (((let 0 = 1))) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:61:14
|
||||
|
|
||||
LL | while (((let 0 = 1))) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:64:12
|
||||
|
|
||||
LL | while (let 0 = 1) && true {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:64:12
|
||||
|
|
||||
LL | while (let 0 = 1) && true {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:67:20
|
||||
|
|
||||
LL | while true && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:67:20
|
||||
|
|
||||
LL | while true && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:70:12
|
||||
|
|
||||
LL | while (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:70:12
|
||||
|
|
||||
LL | while (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:70:27
|
||||
|
|
||||
LL | while (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:70:27
|
||||
|
|
||||
LL | while (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:74:38
|
||||
|
|
||||
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:74:38
|
||||
|
|
||||
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:74:51
|
||||
|
|
||||
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:74:38
|
||||
|
|
||||
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:74:64
|
||||
|
|
||||
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:74:38
|
||||
|
|
||||
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:98:9
|
||||
|
|
||||
LL | if &let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:101:9
|
||||
|
|
||||
LL | if !let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:103:9
|
||||
|
|
||||
LL | if *let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:105:9
|
||||
|
|
||||
LL | if -let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:113:9
|
||||
|
|
||||
LL | if (let 0 = 0)? {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:116:16
|
||||
|
|
||||
LL | if true || let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `||` operators are not supported in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:116:13
|
||||
|
|
||||
LL | if true || let 0 = 0 {}
|
||||
| ^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:118:17
|
||||
|
|
||||
LL | if (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:120:25
|
||||
|
|
||||
LL | if true && (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:122:25
|
||||
|
|
||||
LL | if true || (true && let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:126:12
|
||||
|
|
||||
LL | if x = let 0 = 0 {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:129:15
|
||||
|
|
||||
LL | if true..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:132:11
|
||||
|
|
||||
LL | if ..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:134:9
|
||||
|
|
||||
LL | if (let 0 = 0).. {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:138:8
|
||||
|
|
||||
LL | if let Range { start: _, end: _ } = true..true && false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:141:8
|
||||
|
|
||||
LL | if let Range { start: _, end: _ } = true..true || false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:147:8
|
||||
|
|
||||
LL | if let Range { start: F, end } = F..|| true {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:153:8
|
||||
|
|
||||
LL | if let Range { start: true, end } = t..&&false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:157:19
|
||||
|
|
||||
LL | if let true = let true = true {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:163:12
|
||||
|
|
||||
LL | while &let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:166:12
|
||||
|
|
||||
LL | while !let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:168:12
|
||||
|
|
||||
LL | while *let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:170:12
|
||||
|
|
||||
LL | while -let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:178:12
|
||||
|
|
||||
LL | while (let 0 = 0)? {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:181:19
|
||||
|
|
||||
LL | while true || let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `||` operators are not supported in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:181:16
|
||||
|
|
||||
LL | while true || let 0 = 0 {}
|
||||
| ^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:183:20
|
||||
|
|
||||
LL | while (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:185:28
|
||||
|
|
||||
LL | while true && (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:187:28
|
||||
|
|
||||
LL | while true || (true && let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:191:15
|
||||
|
|
||||
LL | while x = let 0 = 0 {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:194:18
|
||||
|
|
||||
LL | while true..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:197:14
|
||||
|
|
||||
LL | while ..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:199:12
|
||||
|
|
||||
LL | while (let 0 = 0).. {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:203:11
|
||||
|
|
||||
LL | while let Range { start: _, end: _ } = true..true && false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:206:11
|
||||
|
|
||||
LL | while let Range { start: _, end: _ } = true..true || false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:212:11
|
||||
|
|
||||
LL | while let Range { start: F, end } = F..|| true {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:218:11
|
||||
|
|
||||
LL | while let Range { start: true, end } = t..&&false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:222:22
|
||||
|
|
||||
LL | while let true = let true = true {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:239:6
|
||||
|
|
||||
LL | &let 0 = 0;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:242:6
|
||||
|
|
||||
LL | !let 0 = 0;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:244:6
|
||||
|
|
||||
LL | *let 0 = 0;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:246:6
|
||||
|
|
||||
LL | -let 0 = 0;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:248:13
|
||||
|
|
||||
LL | let _ = let _ = 3;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:256:6
|
||||
|
|
||||
LL | (let 0 = 0)?;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:259:13
|
||||
|
|
||||
LL | true || let 0 = 0;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:261:14
|
||||
|
|
||||
LL | (true || let 0 = 0);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:263:22
|
||||
|
|
||||
LL | true && (true || let 0 = 0);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:267:9
|
||||
|
|
||||
LL | x = let 0 = 0;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:270:12
|
||||
|
|
||||
LL | true..(let 0 = 0);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:272:8
|
||||
|
|
||||
LL | ..(let 0 = 0);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:274:6
|
||||
|
|
||||
LL | (let 0 = 0)..;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:277:6
|
||||
|
|
||||
LL | (let Range { start: _, end: _ } = true..true || false);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:281:6
|
||||
|
|
||||
LL | (let true = let true = true);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:281:17
|
||||
|
|
||||
LL | (let true = let true = true);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:287:25
|
||||
|
|
||||
LL | let x = true && let y = 1;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:293:19
|
||||
|
|
||||
LL | [1, 2, 3][let _ = ()]
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:298:6
|
||||
|
|
||||
LL | &let 0 = 0
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:309:17
|
||||
|
|
||||
LL | true && let 1 = 1
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:314:17
|
||||
|
|
||||
LL | true && let 1 = 1
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:319:17
|
||||
|
|
||||
LL | true && let 1 = 1
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:330:17
|
||||
|
|
||||
LL | true && let 1 = 1
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/disallowed-positions.rs:330:9
|
||||
|
|
||||
LL | true && let 1 = 1
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: enclose the `const` expression in braces
|
||||
|
|
||||
LL | { true && let 1 = 1 }
|
||||
| + +
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:340:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && true) {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:340:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && true) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:344:9
|
||||
|
|
||||
LL | if (let Some(a) = opt) && true {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:344:9
|
||||
|
|
||||
LL | if (let Some(a) = opt) && true {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:347:9
|
||||
|
|
||||
LL | if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:347:9
|
||||
|
|
||||
LL | if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:347:32
|
||||
|
|
||||
LL | if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:347:32
|
||||
|
|
||||
LL | if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:355:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:355:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:355:31
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:355:31
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:359:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:359:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:359:31
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:359:31
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:363:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (true)) && true {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||
--> $DIR/disallowed-positions.rs:363:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (true)) && true {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:383:22
|
||||
|
|
||||
LL | let x = (true && let y = 1);
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:388:20
|
||||
|
|
||||
LL | ([1, 2, 3][let _ = ()])
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: aborting due to 89 previous errors
|
||||
|
@ -1,3 +1,4 @@
|
||||
//@ revisions: no_feature feature nothing
|
||||
// Here we test that `lowering` behaves correctly wrt. `let $pats = $expr` expressions.
|
||||
//
|
||||
// We want to make sure that `let` is banned in situations other than:
|
||||
@ -17,7 +18,8 @@
|
||||
//
|
||||
// To that end, we check some positions which is not part of the language above.
|
||||
|
||||
#![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test.
|
||||
// Avoid inflating `.stderr` with overzealous gates (or test what happens if you disable the gate)
|
||||
#![cfg_attr(not(no_feature), feature(let_chains))]
|
||||
|
||||
#![allow(irrefutable_let_patterns)]
|
||||
|
||||
@ -25,6 +27,7 @@
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn _if() {
|
||||
if (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -46,8 +49,11 @@ fn _if() {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
//[no_feature]~| ERROR `let` expressions in this position are unstable
|
||||
//[no_feature]~| ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn _while() {
|
||||
while (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -69,8 +75,11 @@ fn _while() {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
//[no_feature]~| ERROR `let` expressions in this position are unstable
|
||||
//[no_feature]~| ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn _macros() {
|
||||
macro_rules! use_expr {
|
||||
($e:expr) => {
|
||||
@ -79,11 +88,12 @@ macro_rules! use_expr {
|
||||
}
|
||||
}
|
||||
use_expr!((let 0 = 1 && 0 == 0));
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//[feature,no_feature]~^ ERROR expected expression, found `let` statement
|
||||
use_expr!((let 0 = 1));
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//[feature,no_feature]~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn nested_within_if_expr() {
|
||||
if &let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -97,7 +107,7 @@ fn nested_within_if_expr() {
|
||||
|
||||
fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
if let 0 = 0? {}
|
||||
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
//[feature,no_feature]~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
Ok(())
|
||||
}
|
||||
if (let 0 = 0)? {}
|
||||
@ -118,7 +128,7 @@ fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
|
||||
if true..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
if ..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
if (let 0 = 0).. {}
|
||||
@ -127,27 +137,28 @@ fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
// Binds as `(let ... = true)..true &&/|| false`.
|
||||
if let Range { start: _, end: _ } = true..true && false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
if let Range { start: _, end: _ } = true..true || false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| 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 expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
|
||||
// Binds as `(let Range { start: true, end } = t)..(&&false)`.
|
||||
let t = &&true;
|
||||
if let Range { start: true, end } = t..&&false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
|
||||
if let true = let true = true {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn nested_within_while_expr() {
|
||||
while &let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -161,7 +172,7 @@ fn nested_within_while_expr() {
|
||||
|
||||
fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
while let 0 = 0? {}
|
||||
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
//[feature,no_feature]~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
Ok(())
|
||||
}
|
||||
while (let 0 = 0)? {}
|
||||
@ -182,7 +193,7 @@ fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
|
||||
while true..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
while ..(let 0 = 0) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
while (let 0 = 0).. {}
|
||||
@ -191,27 +202,28 @@ fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
// Binds as `(let ... = true)..true &&/|| false`.
|
||||
while let Range { start: _, end: _ } = true..true && false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
while let Range { start: _, end: _ } = true..true || false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| 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 expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
|
||||
// Binds as `(let Range { start: true, end } = t)..(&&false)`.
|
||||
let t = &&true;
|
||||
while let Range { start: true, end } = t..&&false {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR mismatched types
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
|
||||
while let true = let true = true {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn not_error_because_clarified_intent() {
|
||||
if let Range { start: _, end: _ } = (true..true || false) { }
|
||||
|
||||
@ -222,6 +234,7 @@ fn not_error_because_clarified_intent() {
|
||||
while let Range { start: _, end: _ } = (true..true && false) { }
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn outside_if_and_while_expr() {
|
||||
&let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -232,10 +245,12 @@ fn outside_if_and_while_expr() {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
-let 0 = 0;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
let _ = let _ = 3;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
let 0 = 0?;
|
||||
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
//[feature,no_feature]~^ ERROR the `?` operator can only be applied to values that implement `Try`
|
||||
Ok(())
|
||||
}
|
||||
(let 0 = 0)?;
|
||||
@ -260,8 +275,8 @@ fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
(let Range { start: _, end: _ } = true..true || false);
|
||||
//~^ ERROR mismatched types
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//[feature,no_feature]~| ERROR mismatched types
|
||||
|
||||
(let true = let true = true);
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -285,6 +300,7 @@ fn _check_try_binds_tighter() -> Result<(), ()> {
|
||||
}
|
||||
|
||||
// Let's make sure that `let` inside const generic arguments are considered.
|
||||
#[cfg(not(nothing))]
|
||||
fn inside_const_generic_arguments() {
|
||||
struct A<const B: bool>;
|
||||
impl<const B: bool> A<{B}> { const O: u32 = 5; }
|
||||
@ -317,6 +333,7 @@ fn inside_const_generic_arguments() {
|
||||
>::O == 5 {}
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn with_parenthesis() {
|
||||
let opt = Some(Some(1i32));
|
||||
|
||||
@ -332,6 +349,7 @@ fn with_parenthesis() {
|
||||
//~| ERROR expected expression, found `let` statement
|
||||
}
|
||||
if let Some(a) = opt && (true && true) {
|
||||
//[no_feature]~^ ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
|
||||
if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
@ -347,14 +365,18 @@ fn with_parenthesis() {
|
||||
}
|
||||
|
||||
if (true && (true)) && let Some(a) = opt {
|
||||
//[no_feature]~^ ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
if (true) && let Some(a) = opt {
|
||||
//[no_feature]~^ ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
if true && let Some(a) = opt {
|
||||
//[no_feature]~^ ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
|
||||
let fun = || true;
|
||||
if let true = (true && fun()) && (true) {
|
||||
//[no_feature]~^ ERROR `let` expressions in this position are unstable
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
|
Loading…
Reference in New Issue
Block a user