Skip to content

rewrite ... to ..= as an idiom lint for Rust 2018 edition #51043

Description

@nikomatsakis

Current status

Implemented in #51149 but currently not marked as automatically applicable due to this issue which is explained below

Activity

  1. nikomatsakis commented on May 24, 2018

    @nikomatsakis
    ContributorAuthor

    Do we have an existing lint for this?

  2. zackmdavis commented on May 25, 2018

    @zackmdavis
    Contributor

    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.)

  3. kennytm commented on May 26, 2018

    @kennytm
    Member

    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
            _ => {}
        }
    }
  4. nikomatsakis commented on May 30, 2018

    @nikomatsakis
    ContributorAuthor

    @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.

  5. 16 remaining items

  6. added
    C-enhancementCategory: 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.
    on Oct 2, 2018
  7. pnkfelix commented on Nov 8, 2018

    @pnkfelix
    Contributor

    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?

  8. self-assigned this
    on Nov 8, 2018
  9. pnkfelix commented on Nov 8, 2018

    @pnkfelix
    Contributor

    more triage notes: P-high. @varkor has agreed to take this on and/or mentor it.

  10. added a commit that references this issue on Nov 12, 2018
  11. nikomatsakis commented on Nov 13, 2018

    @nikomatsakis
    ContributorAuthor

    Removing from the milestone, as idiom lints are not part of the Rust 2018 release.

  12. removed this from the Rust 2018 Release milestone on Nov 13, 2018
  13. added a commit that references this issue on Nov 15, 2018
  14. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    and removed on Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-edition-2018Area: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.F-rust_2018_preview`#![feature(rust_2018_preview)]`P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-epochWorking group: Epoch (2018) management

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions