Repository navigation
rewrite ... to ..= as an idiom lint for Rust 2018 edition #51043
Description
Activity
- addedF-rust_2018_preview`#![feature(rust_2018_preview)]``#![feature(rust_2018_preview)]`
on May 24, 2018 Do we have an existing lint for this?
- addedWG-epochWorking group: Epoch (2018) managementWorking group: Epoch (2018) management
on May 24, 2018 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.)Reacted by scottmcmOne remaining issue of
a..=bpattern is #48501. When stabilizinga..=b, to avoid the confusing interpretation of&a...b, in the following example:fn main() { match &5 { &3...6 => {} _ => {} } }
if we just
s/.../..=/gthe code will error witherror: 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 befn main() { match &5 { 3..=6 => {} // no &, no (), no whatever _ => {} } }
Reacted by Mateusz Mikuła and JubileeReacted by scottmcm and JubileeIf 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.
Reacted by James Beau16 remaining items
- addedC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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.
on Oct 2, 2018 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.
Reacted by James Beau- added a commit that references this issue
on Sep 14, 2019 - addedA-edition-2018Area: The 2018 editionArea: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.and removed
on Dec 21, 2024
Current status
Implemented in #51149 but currently not marked as automatically applicable due to this issue which is explained below