-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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:
0..<A>::b(); // OK
Oh well.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.