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:
commit
1eee532eff
4 changed files with 51 additions and 13 deletions
|
|
@ -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`
|
||||
|
|
|
|||
5
src/test/ui/parser/if-in-in.rs
Normal file
5
src/test/ui/parser/if-in-in.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
for i in in 1..2 {
|
||||
println!("{}", i);
|
||||
}
|
||||
}
|
||||
13
src/test/ui/parser/if-in-in.stderr
Normal file
13
src/test/ui/parser/if-in-in.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue