Skip to content

Moving AsciiExt methods to types is a footgun for maintaining backwards compatibility #46510

Closed
@shepmaster

Description

@shepmaster

In Rust 1.22.1, this code compiles:

use std::ascii::AsciiExt;

fn main() {
    "a".eq_ignore_ascii_case("a");
}

In Rust 1.23.0.beta.1, it issues a warning:

warning: unused import: `std::ascii::AsciiExt`
 --> src/main.rs:1:5
  |
1 | use std::ascii::AsciiExt;
  |     ^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

My tidiness kicks in and I remove the trait — no one wants warnings, right?

However, if I remove this trait, my crates will no longer compile on older versions of Rust. I've actually been bitten by this twice now, and one of those times has been released to crates.io. 😞

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions