Skip to content

Commit

Permalink
Remove unused AsciiExt imports and fix tests related to ascii methods
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LukasKalbertodt committed Nov 3, 2017
1 parent 1916e3c commit da57580
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/liballoc/benches/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,12 @@ make_test!(match_indices_a_str, s, s.match_indices("a").count());
make_test!(split_a_str, s, s.split("a").count());

make_test!(trim_ascii_char, s, {
use std::ascii::AsciiExt;
s.trim_matches(|c: char| c.is_ascii())
});
make_test!(trim_left_ascii_char, s, {
use std::ascii::AsciiExt;
s.trim_left_matches(|c: char| c.is_ascii())
});
make_test!(trim_right_ascii_char, s, {
use std::ascii::AsciiExt;
s.trim_right_matches(|c: char| c.is_ascii())
});

Expand Down
1 change: 0 additions & 1 deletion src/liballoc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ impl<'a, B: ?Sized> Cow<'a, B>
/// # Examples
///
/// ```
/// use std::ascii::AsciiExt;
/// use std::borrow::Cow;
///
/// let mut cow = Cow::Borrowed("foo");
Expand Down
4 changes: 0 additions & 4 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ impl str {
/// # Examples
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let mut v = String::from("hello");
/// // correct length
/// assert!(v.get_mut(0..5).is_some());
Expand Down Expand Up @@ -617,8 +615,6 @@ impl str {
/// Basic usage:
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let mut s = "Per Martin-Löf".to_string();
/// {
/// let (first, last) = s.split_at_mut(3);
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,6 @@ impl String {
/// Basic usage:
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let mut s = String::from("foobar");
/// let s_mut_str = s.as_mut_str();
///
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ fn test_split_at() {

#[test]
fn test_split_at_mut() {
use std::ascii::AsciiExt;
let mut s = "Hello World".to_string();
{
let (a, b) = s.split_at_mut(5);
Expand Down
3 changes: 0 additions & 3 deletions src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::ascii::AsciiExt;
use std::borrow::Cow;
use std::mem::size_of;
use std::panic;
Expand Down Expand Up @@ -966,5 +965,3 @@ fn drain_filter_complex() {
assert_eq!(vec, vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19]);
}
}


2 changes: 0 additions & 2 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,6 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let mut vec = vec!["foo", "bar", "Bar", "baz", "bar"];
///
/// vec.dedup_by(|a, b| a.eq_ignore_ascii_case(b));
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use hir::def_id::{CrateNum, LOCAL_CRATE};
use hir::intravisit::{self, FnKind};
use hir;
use session::Session;
#[cfg(stage0)]
use std::ascii::AsciiExt;
use std::hash;
use syntax::ast;
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::mem;
use std::fmt::{self, Write};
use std::ops;
#[cfg(stage0)]
use std::ascii::AsciiExt;

use syntax::symbol::Symbol;
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
//! both occur before the crate is rendered.
pub use self::ExternalLocation::*;

#[cfg(stage0)]
use std::ascii::AsciiExt;
use std::cell::RefCell;
use std::cmp::Ordering;
Expand Down
8 changes: 5 additions & 3 deletions src/libstd/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use iter::FusedIterator;
/// ```
/// use std::ascii::AsciiExt;
///
/// assert_eq!("café".to_ascii_uppercase(), "CAFÉ");
/// assert_eq!("café".to_ascii_uppercase(), "CAFé");
/// assert_eq!(AsciiExt::to_ascii_uppercase("café"), "CAFÉ");
/// assert_eq!(AsciiExt::to_ascii_uppercase("café"), "CAFé");
/// ```
///
/// In the first example, the lowercased string is represented `"cafe\u{301}"`
Expand Down Expand Up @@ -681,7 +681,9 @@ impl fmt::Debug for EscapeDefault {

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

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/deref-suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ error[E0308]: mismatched types
- .escape_debug()
- .escape_default()
- .escape_unicode()
- .to_lowercase()
- .to_uppercase()
- .to_ascii_lowercase()
- .to_ascii_uppercase()

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

0 comments on commit da57580

Please sign in to comment.