Skip to content

Commit c09b9f9

Browse files
committed
Deprecate the AsciiExt trait in favor of inherent methods
The trait and some of its methods are stable and will remain. Some of the newer methods are unstable and can be removed later. Fixes #39658
1 parent cc34ca1 commit c09b9f9

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/libcore/tests/ascii.rs

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
use core::char::from_u32;
12-
use std::ascii::AsciiExt;
1312

1413
#[test]
1514
fn test_is_ascii() {
@@ -143,8 +142,6 @@ macro_rules! assert_all {
143142
stringify!($what), b);
144143
}
145144
}
146-
assert!($str.$what());
147-
assert!($str.as_bytes().$what());
148145
)+
149146
}};
150147
($what:ident, $($str:tt),+,) => (assert_all!($what,$($str),+))

src/libstd/ascii.rs

+17
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub use core::ascii::{EscapeDefault, escape_default};
5252
///
5353
/// [combining character]: https://en.wikipedia.org/wiki/Combining_character
5454
#[stable(feature = "rust1", since = "1.0.0")]
55+
#[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")]
5556
pub trait AsciiExt {
5657
/// Container type for copied ASCII characters.
5758
#[stable(feature = "rust1", since = "1.0.0")]
@@ -84,6 +85,7 @@ pub trait AsciiExt {
8485
/// [`make_ascii_uppercase`]: #tymethod.make_ascii_uppercase
8586
/// [`str::to_uppercase`]: ../primitive.str.html#method.to_uppercase
8687
#[stable(feature = "rust1", since = "1.0.0")]
88+
#[allow(deprecated)]
8789
fn to_ascii_uppercase(&self) -> Self::Owned;
8890

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

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

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

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

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

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

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

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

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

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

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

@@ -354,6 +367,7 @@ macro_rules! delegating_ascii_ctype_methods {
354367
}
355368

356369
#[stable(feature = "rust1", since = "1.0.0")]
370+
#[allow(deprecated)]
357371
impl AsciiExt for u8 {
358372
type Owned = u8;
359373

@@ -362,6 +376,7 @@ impl AsciiExt for u8 {
362376
}
363377

364378
#[stable(feature = "rust1", since = "1.0.0")]
379+
#[allow(deprecated)]
365380
impl AsciiExt for char {
366381
type Owned = char;
367382

@@ -370,6 +385,7 @@ impl AsciiExt for char {
370385
}
371386

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

@@ -427,6 +443,7 @@ impl AsciiExt for [u8] {
427443
}
428444

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

src/libstd/sys/windows/process.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

13-
use ascii::AsciiExt;
1413
use collections::BTreeMap;
1514
use env::split_paths;
1615
use env;

src/libstd/sys_common/wtf8.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
use core::str::next_code_point;
2929

30-
use ascii::*;
3130
use borrow::Cow;
3231
use char;
3332
use fmt;
@@ -871,24 +870,22 @@ impl Hash for Wtf8 {
871870
}
872871
}
873872

874-
impl AsciiExt for Wtf8 {
875-
type Owned = Wtf8Buf;
876-
877-
fn is_ascii(&self) -> bool {
873+
impl Wtf8 {
874+
pub fn is_ascii(&self) -> bool {
878875
self.bytes.is_ascii()
879876
}
880-
fn to_ascii_uppercase(&self) -> Wtf8Buf {
877+
pub fn to_ascii_uppercase(&self) -> Wtf8Buf {
881878
Wtf8Buf { bytes: self.bytes.to_ascii_uppercase() }
882879
}
883-
fn to_ascii_lowercase(&self) -> Wtf8Buf {
880+
pub fn to_ascii_lowercase(&self) -> Wtf8Buf {
884881
Wtf8Buf { bytes: self.bytes.to_ascii_lowercase() }
885882
}
886-
fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool {
883+
pub fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool {
887884
self.bytes.eq_ignore_ascii_case(&other.bytes)
888885
}
889886

890-
fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
891-
fn make_ascii_lowercase(&mut self) { self.bytes.make_ascii_lowercase() }
887+
pub fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
888+
pub fn make_ascii_lowercase(&mut self) { self.bytes.make_ascii_lowercase() }
892889
}
893890

894891
#[cfg(test)]

src/test/run-pass/issue-10683.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// pretty-expanded FIXME #23616
1212

13-
use std::ascii::AsciiExt;
14-
1513
static NAME: &'static str = "hello world";
1614

1715
fn main() {

0 commit comments

Comments
 (0)