Current status
Implemented in https://github.com/rust-lang/rust/pull/51149 but currently not marked as automatically applicable due to this issue which is explained below
Do we have an existing lint for this?
If we hope to someday get rid of ... in patterns (the current description of #28237 describes it as "(silently) deprecated"), wouldn't we want a future-incompatible lint rather than an idiom lint? (... in expressions is already illegal.)
One remaining issue of a..=b pattern is #48501. When stabilizing a..=b, to avoid the confusing interpretation of &a...b, in the following example:
fn main() {
match &5 {
&3...6 => {}
_ => {}
}
}
if we just s/.../..=/g the code will error with
error: the range pattern here has ambiguous interpretation
--> src/main.rs:3:10
|
3 | &3..=6 => {}
| ^^^^^ help: add parentheses to clarify the precedence: `(3 ..=6)`
Note that pattern_parentheses (#48500) is still unstable 馃檭. However, given that default binding modes (#42640) is already stable, an even more idiomatic fix would probably be
fn main() {
match &5 {
3..=6 => {} // no &, no (), no whatever
_ => {}
}
}
@zackmdavis
If we hope to someday get rid of ... in patterns (the current description of #28237 describes it as "(silently) deprecated"), wouldn't we want a future-incompatible lint rather than an idiom lint? (... in expressions is already illegal.)
I classified it as an idiom lint because the code will not cause a hard error in the new edition, even if it is frowned upon.
@zackmdavis if you've got a moment, can you write up a listing of what's left after #51149 landed?
if you've got a moment, can you write up a listing of what's left after #51149 landed?
@alexcrichton: the comment above by @kennytm should still be addressed; the lint suggestion is marked as maybe-incorrect for this reason. If pattern-parentheses are stabilized (which itself reportedly needs more testing), using them for a correct suggestion when needed will be very easy.
Ok great, thanks!
visited for T-compiler triage. It seems like it was blocked on stabilization of the pattern-parentheses feature. So what are the next steps, and who wants to own this?
more triage notes: P-high. @varkor has agreed to take this on and/or mentor it.
Removing from the milestone, as idiom lints are not part of the Rust 2018 release.
Most helpful comment
One remaining issue of
a..=bpattern is #48501. When stabilizinga..=b, to avoid the confusing interpretation of&a...b, in the following example:if we just
s/.../..=/gthe code will error withNote that
pattern_parentheses(#48500) is still unstable 馃檭. However, given that default binding modes (#42640) is already stable, an even more idiomatic fix would probably be