Rollup merge of #132828 - est31:let_chains_parsing_tests, r=compiler-errors
Additional tests to ensure let is rejected during parsing In the original stabilization PR, @ `compiler-errors` has [pointed out](https://github.com/rust-lang/rust/pull/94927#issuecomment-1165156328) that #97295 wasn't enough to address the concerns about having `let` in expressions being rejected at parsing time, instead of later. Thankfully, since then the situation has been greatly improved by #115677. This PR adds some additional tests to `disallowed-positions.rs`, and adds two additional revisions to the "normal" case which is now given the `feature` name: * `no_feature`: Added to incorporate `disallowed-positions-without-feature-gate.rs` into the file, reducing duplication. * `nothing`: like feature, but all functions are cfg'd out. Ensures that the errors are really emitted during parsing. cc tracking issue #53667
This commit is contained in:
commit
c19d56c902
@ -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,990 @@
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:33: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:33:9
|
||||
|
|
||||
LL | if (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:36: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:36:11
|
||||
|
|
||||
LL | if (((let 0 = 1))) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:39: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:39:9
|
||||
|
|
||||
LL | if (let 0 = 1) && true {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:42: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:42:17
|
||||
|
|
||||
LL | if true && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:45: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:45:9
|
||||
|
|
||||
LL | if (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:45: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:45:24
|
||||
|
|
||||
LL | if (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:49: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:49: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:49: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:49: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:49: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:49: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:59: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:59:12
|
||||
|
|
||||
LL | while (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:62: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:62:14
|
||||
|
|
||||
LL | while (((let 0 = 1))) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:65: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:65:12
|
||||
|
|
||||
LL | while (let 0 = 1) && true {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:68: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:68:20
|
||||
|
|
||||
LL | while true && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:71: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:71:12
|
||||
|
|
||||
LL | while (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:71: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:71:27
|
||||
|
|
||||
LL | while (let 0 = 1) && (let 0 = 1) {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:75: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:75: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:75: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:75: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:75: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:75: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:99: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:102: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:104: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:106: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:114: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:117: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:117:13
|
||||
|
|
||||
LL | if true || let 0 = 0 {}
|
||||
| ^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:119: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:121: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:123: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:127: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:130: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:133: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:135: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:139: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:142: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:148: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:154: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:158: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:161:15
|
||||
|
|
||||
LL | if return let 0 = 0 {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:164:21
|
||||
|
|
||||
LL | loop { if break let 0 = 0 {} }
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:167:15
|
||||
|
|
||||
LL | if (match let 0 = 0 { _ => { false } }) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:170:9
|
||||
|
|
||||
LL | if (let 0 = 0, false).1 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:173: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:177:13
|
||||
|
|
||||
LL | if (let 0 = 0).await {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:181:12
|
||||
|
|
||||
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:184: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:190: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:193: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:195: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:197: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:205: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:208: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:208:16
|
||||
|
|
||||
LL | while true || let 0 = 0 {}
|
||||
| ^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:210: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:212: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:214: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:218: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:221: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:224: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:226: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:230: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:233: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:239: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:245: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:249: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:252:18
|
||||
|
|
||||
LL | while return let 0 = 0 {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:255:39
|
||||
|
|
||||
LL | 'outer: loop { while break 'outer let 0 = 0 {} }
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:258:18
|
||||
|
|
||||
LL | while (match let 0 = 0 { _ => { false } }) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:261:12
|
||||
|
|
||||
LL | while (let 0 = 0, false).1 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:264: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:268:16
|
||||
|
|
||||
LL | while (let 0 = 0).await {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:272:15
|
||||
|
|
||||
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:275: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:292: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:295: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:297: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:299: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:301: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:309: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:312: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:314: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:316: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:320: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:323: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:325: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:327: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:330: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:334: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:334: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:340: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:346: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:351: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:362: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:367: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:372: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:383: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:383: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:393: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:393:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && true) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:397: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:397:9
|
||||
|
|
||||
LL | if (let Some(a) = opt) && true {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:400: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:400:9
|
||||
|
|
||||
LL | if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:400: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:400:32
|
||||
|
|
||||
LL | if (let Some(a) = opt) && (let Some(b) = a) {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:408: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:408:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:408: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:408:31
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:412: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:412:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:412: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:412:31
|
||||
|
|
||||
LL | if (let Some(a) = opt && (let Some(b) = a)) && true {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:416: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:416:9
|
||||
|
|
||||
LL | if (let Some(a) = opt && (true)) && true {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/disallowed-positions.rs:436: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:441:20
|
||||
|
|
||||
LL | ([1, 2, 3][let _ = ()])
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error: aborting due to 105 previous errors
|
||||
|
@ -1,3 +1,5 @@
|
||||
//@ revisions: no_feature feature nothing
|
||||
//@ edition: 2021
|
||||
// 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 +19,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 +28,7 @@
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn _if() {
|
||||
if (let 0 = 1) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -46,8 +50,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 +76,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 +89,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 +108,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 +129,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 +138,54 @@ 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
|
||||
|
||||
if return let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
loop { if break let 0 = 0 {} }
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if (match let 0 = 0 { _ => { false } }) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if (let 0 = 0, false).1 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
if (let 0 = 0,) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
async fn foo() {
|
||||
if (let 0 = 0).await {}
|
||||
//~^ 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
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn nested_within_while_expr() {
|
||||
while &let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
@ -161,7 +199,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 +220,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 +229,54 @@ 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
|
||||
|
||||
while return let 0 = 0 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
'outer: loop { while break 'outer let 0 = 0 {} }
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while (match let 0 = 0 { _ => { false } }) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while (let 0 = 0, false).1 {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
while (let 0 = 0,) {}
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
|
||||
async fn foo() {
|
||||
while (let 0 = 0).await {}
|
||||
//~^ 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
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn not_error_because_clarified_intent() {
|
||||
if let Range { start: _, end: _ } = (true..true || false) { }
|
||||
|
||||
@ -222,6 +287,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 +298,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 +328,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 +353,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 +386,7 @@ fn inside_const_generic_arguments() {
|
||||
>::O == 5 {}
|
||||
}
|
||||
|
||||
#[cfg(not(nothing))]
|
||||
fn with_parenthesis() {
|
||||
let opt = Some(Some(1i32));
|
||||
|
||||
@ -332,6 +402,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 +418,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