Skip to content

Commit da57580

Browse files
Remove unused AsciiExt imports and fix tests related to ascii methods
Many AsciiExt imports have become useless thanks to the inherent ascii methods added in the last commits. These were removed. In some places, I fully specified the ascii method being called to enforce usage of the AsciiExt trait. Note that some imports are not removed but tagged with a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii methods are not yet available in stage0. All those imports will be removed later. Additionally, failing tests were fixed. The test suite should exit successfully now.
1 parent 1916e3c commit da57580

File tree

12 files changed

+10
-21
lines changed

12 files changed

+10
-21
lines changed

src/liballoc/benches/str.rs

-3
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,12 @@ make_test!(match_indices_a_str, s, s.match_indices("a").count());
272272
make_test!(split_a_str, s, s.split("a").count());
273273

274274
make_test!(trim_ascii_char, s, {
275-
use std::ascii::AsciiExt;
276275
s.trim_matches(|c: char| c.is_ascii())
277276
});
278277
make_test!(trim_left_ascii_char, s, {
279-
use std::ascii::AsciiExt;
280278
s.trim_left_matches(|c: char| c.is_ascii())
281279
});
282280
make_test!(trim_right_ascii_char, s, {
283-
use std::ascii::AsciiExt;
284281
s.trim_right_matches(|c: char| c.is_ascii())
285282
});
286283

src/liballoc/borrow.rs

-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ impl<'a, B: ?Sized> Cow<'a, B>
191191
/// # Examples
192192
///
193193
/// ```
194-
/// use std::ascii::AsciiExt;
195194
/// use std::borrow::Cow;
196195
///
197196
/// let mut cow = Cow::Borrowed("foo");

src/liballoc/str.rs

-4
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ impl str {
390390
/// # Examples
391391
///
392392
/// ```
393-
/// use std::ascii::AsciiExt;
394-
///
395393
/// let mut v = String::from("hello");
396394
/// // correct length
397395
/// assert!(v.get_mut(0..5).is_some());
@@ -617,8 +615,6 @@ impl str {
617615
/// Basic usage:
618616
///
619617
/// ```
620-
/// use std::ascii::AsciiExt;
621-
///
622618
/// let mut s = "Per Martin-Löf".to_string();
623619
/// {
624620
/// let (first, last) = s.split_at_mut(3);

src/liballoc/string.rs

-2
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,6 @@ impl String {
773773
/// Basic usage:
774774
///
775775
/// ```
776-
/// use std::ascii::AsciiExt;
777-
///
778776
/// let mut s = String::from("foobar");
779777
/// let s_mut_str = s.as_mut_str();
780778
///

src/liballoc/tests/str.rs

-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ fn test_split_at() {
706706

707707
#[test]
708708
fn test_split_at_mut() {
709-
use std::ascii::AsciiExt;
710709
let mut s = "Hello World".to_string();
711710
{
712711
let (a, b) = s.split_at_mut(5);

src/liballoc/tests/vec.rs

-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::ascii::AsciiExt;
1211
use std::borrow::Cow;
1312
use std::mem::size_of;
1413
use std::panic;
@@ -966,5 +965,3 @@ fn drain_filter_complex() {
966965
assert_eq!(vec, vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19]);
967966
}
968967
}
969-
970-

src/liballoc/vec.rs

-2
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,6 @@ impl<T> Vec<T> {
853853
/// # Examples
854854
///
855855
/// ```
856-
/// use std::ascii::AsciiExt;
857-
///
858856
/// let mut vec = vec!["foo", "bar", "Bar", "baz", "bar"];
859857
///
860858
/// vec.dedup_by(|a, b| a.eq_ignore_ascii_case(b));

src/librustc/lint/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use hir::def_id::{CrateNum, LOCAL_CRATE};
3838
use hir::intravisit::{self, FnKind};
3939
use hir;
4040
use session::Session;
41+
#[cfg(stage0)]
4142
use std::ascii::AsciiExt;
4243
use std::hash;
4344
use syntax::ast;

src/librustdoc/clean/cfg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::mem;
1616
use std::fmt::{self, Write};
1717
use std::ops;
18+
#[cfg(stage0)]
1819
use std::ascii::AsciiExt;
1920

2021
use syntax::symbol::Symbol;

src/librustdoc/html/render.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
//! both occur before the crate is rendered.
3535
pub use self::ExternalLocation::*;
3636

37+
#[cfg(stage0)]
3738
use std::ascii::AsciiExt;
3839
use std::cell::RefCell;
3940
use std::cmp::Ordering;

src/libstd/ascii.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ use iter::FusedIterator;
3838
/// ```
3939
/// use std::ascii::AsciiExt;
4040
///
41-
/// assert_eq!("café".to_ascii_uppercase(), "CAFÉ");
42-
/// assert_eq!("café".to_ascii_uppercase(), "CAFé");
41+
/// assert_eq!(AsciiExt::to_ascii_uppercase("café"), "CAFÉ");
42+
/// assert_eq!(AsciiExt::to_ascii_uppercase("café"), "CAFé");
4343
/// ```
4444
///
4545
/// In the first example, the lowercased string is represented `"cafe\u{301}"`
@@ -681,7 +681,9 @@ impl fmt::Debug for EscapeDefault {
681681

682682
#[cfg(test)]
683683
mod tests {
684-
use super::*;
684+
//! Note that most of these tests are not testing `AsciiExt` methods, but
685+
//! test inherent ascii methods of char, u8, str and [u8]. `AsciiExt` is
686+
//! just using those methods, though.
685687
use char::from_u32;
686688

687689
#[test]

src/test/ui/deref-suggestion.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ error[E0308]: mismatched types
1010
- .escape_debug()
1111
- .escape_default()
1212
- .escape_unicode()
13-
- .to_lowercase()
14-
- .to_uppercase()
13+
- .to_ascii_lowercase()
14+
- .to_ascii_uppercase()
1515

1616
error[E0308]: mismatched types
1717
--> $DIR/deref-suggestion.rs:23:10

0 commit comments

Comments
 (0)