Rollup merge of #54409 - estebank:remove-in, r=pnkfelix

Detect `for _ in in bar {}` typo

Fix #36611, #52964, without modifying the parsing of emplacement `in` to avoid further problems like #50832.
This commit is contained in:
Pietro Albini 2018-09-22 09:56:37 +02:00 committed by GitHub
commit 1eee532eff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 13 deletions

View file

@ -2,16 +2,20 @@ error: expected `{`, found `and`
--> $DIR/issue-54109-and_instead_of_ampersands.rs:14:10
|
LL | if a and b {
| -- ^^^ help: use `&&` instead of `and` for the boolean operator
| |
| -- ^^^
| | |
| | expected `{`
| | help: use `&&` instead of `and` for the boolean operator
| this `if` statement has a condition, but no block
error: expected `{`, found `or`
--> $DIR/issue-54109-and_instead_of_ampersands.rs:23:10
|
LL | if a or b {
| -- ^^ help: use `||` instead of `or` for the boolean operator
| |
| -- ^^
| | |
| | expected `{`
| | help: use `||` instead of `or` for the boolean operator
| this `if` statement has a condition, but no block
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`

View file

@ -0,0 +1,5 @@
fn main() {
for i in in 1..2 {
println!("{}", i);
}
}

View file

@ -0,0 +1,13 @@
error: expected iterable, found keyword `in`
--> $DIR/if-in-in.rs:2:14
|
LL | for i in in 1..2 {
| ---^^
| |
| help: remove the duplicated `in`
|
= note: if you meant to use emplacement syntax, it is obsolete (for now, anyway)
= note: for more information on the status of emplacement syntax, see <https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>
error: aborting due to previous error