Add diagnostics test for mistyped inclusive ranges
This commit is contained in:
parent
fd406a8865
commit
b56079ec54
2 changed files with 20 additions and 0 deletions
10
src/test/ui/parser/range-inclusive-extra-equals.rs
Normal file
10
src/test/ui/parser/range-inclusive-extra-equals.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Makes sure that a helpful message is shown when someone mistypes
|
||||
// an inclusive range as `..==` rather than `..=`. This is an
|
||||
// easy mistake, because of the resemblance to`==`.
|
||||
// See #86395 for a bit of background.
|
||||
|
||||
pub fn main() {
|
||||
if let 1..==3 = 1 {} //~ERROR unexpected `=` after inclusive range
|
||||
//~|HELP use `..=` instead
|
||||
//~|NOTE inclusive ranges end with a single equals sign
|
||||
}
|
||||
10
src/test/ui/parser/range-inclusive-extra-equals.stderr
Normal file
10
src/test/ui/parser/range-inclusive-extra-equals.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: unexpected `=` after inclusive range
|
||||
--> $DIR/range-inclusive-extra-equals.rs:7:13
|
||||
|
|
||||
LL | if let 1..==3 = 1 {}
|
||||
| ^^^^ help: use `..=` instead
|
||||
|
|
||||
= note: inclusive ranges end with a single equals sign (`..=`)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue