Code
fn foo() {
0..=10; // OK
0..<10; // error (valid in Swift)
}
Current output
error: expected type, found `10`
--> src/lib.rs:3:9
|
3 | 0..<10; // error (valid in Swift)
| ^^ expected type
Desired output
Suggest 0..10.
Rationale and extra context
The syntax ..= for inclusive ranges seems to suggest ..< for exclusive ranges, especially since Swift uses ..< for exclusive ranges.
(Though, Swift doesn't use ..= for inclusive ranges, but rather ….)
I initially thought this would be easy to diagnose since ..< is never legal syntax, but actually it can be legal as part of an exclusive range where the upper bound is an UFCS call:
Oh well.
Code
Current output
Desired output
Suggest
0..10.Rationale and extra context
The syntax
..=for inclusive ranges seems to suggest..<for exclusive ranges, especially since Swift uses..<for exclusive ranges.(Though, Swift doesn't use
..=for inclusive ranges, but rather….)I initially thought this would be easy to diagnose since
..<is never legal syntax, but actually it can be legal as part of an exclusive range where the upper bound is an UFCS call:Oh well.