Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the AsciiExt trait in favor of inherent methods #49109

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/libcore/tests/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use core::char::from_u32;
use std::ascii::AsciiExt;

#[test]
fn test_is_ascii() {
Expand Down Expand Up @@ -143,8 +142,6 @@ macro_rules! assert_all {
stringify!($what), b);
}
}
assert!($str.$what());
assert!($str.as_bytes().$what());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are removed on str and [u8] in favor of explicit Iterator::all: #39658 (comment)

)+
}};
($what:ident, $($str:tt),+,) => (assert_all!($what,$($str),+))
Expand Down
17 changes: 17 additions & 0 deletions src/libstd/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub use core::ascii::{EscapeDefault, escape_default};
///
/// [combining character]: https://en.wikipedia.org/wiki/Combining_character
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
pub trait AsciiExt {
/// Container type for copied ASCII characters.
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -84,6 +85,7 @@ pub trait AsciiExt {
/// [`make_ascii_uppercase`]: #tymethod.make_ascii_uppercase
/// [`str::to_uppercase`]: ../primitive.str.html#method.to_uppercase
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
fn to_ascii_uppercase(&self) -> Self::Owned;

/// Makes a copy of the value in its ASCII lower case equivalent.
Expand All @@ -104,6 +106,7 @@ pub trait AsciiExt {
/// [`make_ascii_lowercase`]: #tymethod.make_ascii_lowercase
/// [`str::to_lowercase`]: ../primitive.str.html#method.to_lowercase
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
fn to_ascii_lowercase(&self) -> Self::Owned;

/// Checks that two values are an ASCII case-insensitive match.
Expand Down Expand Up @@ -162,6 +165,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_alphabetic(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII uppercase character:
Expand All @@ -174,6 +178,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_uppercase(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII lowercase character:
Expand All @@ -186,6 +191,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_lowercase(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII alphanumeric character:
Expand All @@ -199,6 +205,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_alphanumeric(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII decimal digit:
Expand All @@ -211,6 +218,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_digit(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII hexadecimal digit:
Expand All @@ -224,6 +232,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_hexdigit(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII punctuation character:
Expand All @@ -241,6 +250,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_punctuation(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII graphic character:
Expand All @@ -253,6 +263,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_graphic(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII whitespace character:
Expand Down Expand Up @@ -282,6 +293,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_whitespace(&self) -> bool { unimplemented!(); }

/// Checks if the value is an ASCII control character:
Expand All @@ -294,6 +306,7 @@ pub trait AsciiExt {
/// This method will be deprecated in favor of the identically-named
/// inherent methods on `u8`, `char`, `[u8]` and `str`.
#[unstable(feature = "ascii_ctype", issue = "39658")]
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
fn is_ascii_control(&self) -> bool { unimplemented!(); }
}

Expand Down Expand Up @@ -354,6 +367,7 @@ macro_rules! delegating_ascii_ctype_methods {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl AsciiExt for u8 {
type Owned = u8;

Expand All @@ -362,6 +376,7 @@ impl AsciiExt for u8 {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl AsciiExt for char {
type Owned = char;

Expand All @@ -370,6 +385,7 @@ impl AsciiExt for char {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl AsciiExt for [u8] {
type Owned = Vec<u8>;

Expand Down Expand Up @@ -427,6 +443,7 @@ impl AsciiExt for [u8] {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl AsciiExt for str {
type Owned = String;

Expand Down
1 change: 0 additions & 1 deletion src/libstd/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#![unstable(feature = "process_internals", issue = "0")]

use ascii::AsciiExt;
use collections::BTreeMap;
use env::split_paths;
use env;
Expand Down
17 changes: 7 additions & 10 deletions src/libstd/sys_common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

use core::str::next_code_point;

use ascii::*;
use borrow::Cow;
use char;
use fmt;
Expand Down Expand Up @@ -871,24 +870,22 @@ impl Hash for Wtf8 {
}
}

impl AsciiExt for Wtf8 {
type Owned = Wtf8Buf;

fn is_ascii(&self) -> bool {
impl Wtf8 {
pub fn is_ascii(&self) -> bool {
self.bytes.is_ascii()
}
fn to_ascii_uppercase(&self) -> Wtf8Buf {
pub fn to_ascii_uppercase(&self) -> Wtf8Buf {
Wtf8Buf { bytes: self.bytes.to_ascii_uppercase() }
}
fn to_ascii_lowercase(&self) -> Wtf8Buf {
pub fn to_ascii_lowercase(&self) -> Wtf8Buf {
Wtf8Buf { bytes: self.bytes.to_ascii_lowercase() }
}
fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool {
pub fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool {
self.bytes.eq_ignore_ascii_case(&other.bytes)
}

fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
fn make_ascii_lowercase(&mut self) { self.bytes.make_ascii_lowercase() }
pub fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
pub fn make_ascii_lowercase(&mut self) { self.bytes.make_ascii_lowercase() }
}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/issue-10683.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// pretty-expanded FIXME #23616

use std::ascii::AsciiExt;

static NAME: &'static str = "hello world";

fn main() {
Expand Down