summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Kalbertodt <lukas.kalbertodt@gmail.com>2017-10-02 09:50:36 +0200
committerLukas Kalbertodt <lukas.kalbertodt@gmail.com>2017-11-03 21:27:40 +0100
commitda57580736c6d30fec6c4e4442bc5376ac81f245 (patch)
treed56aa1a4da1c032756e8c6ca48c9bb47d3f4114a
parent1916e3c4aad7b0e0de1cfd190819609f55520996 (diff)
downloadrust-da57580736c6d30fec6c4e4442bc5376ac81f245.tar.gz
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.
-rw-r--r--src/liballoc/benches/str.rs3
-rw-r--r--src/liballoc/borrow.rs1
-rw-r--r--src/liballoc/str.rs4
-rw-r--r--src/liballoc/string.rs2
-rw-r--r--src/liballoc/tests/str.rs1
-rw-r--r--src/liballoc/tests/vec.rs3
-rw-r--r--src/liballoc/vec.rs2
-rw-r--r--src/librustc/lint/mod.rs1
-rw-r--r--src/librustdoc/clean/cfg.rs1
-rw-r--r--src/librustdoc/html/render.rs1
-rw-r--r--src/libstd/ascii.rs8
-rw-r--r--src/test/ui/deref-suggestion.stderr4
12 files changed, 10 insertions, 21 deletions
diff --git a/src/liballoc/benches/str.rs b/src/liballoc/benches/str.rs
index fc4063fae92..38c94d4d8b5 100644
--- a/src/liballoc/benches/str.rs
+++ b/src/liballoc/benches/str.rs
@@ -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())
});
diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs
index a662e4b1f4f..e8aff099871 100644
--- a/src/liballoc/borrow.rs
+++ b/src/liballoc/borrow.rs
@@ -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");
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index 2c257b8c736..b75ecb6ea51 100644
--- a/src/liballoc/str.rs
+++ b/src/liballoc/str.rs
@@ -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());
@@ -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);
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 6d0bb264df1..25fcc1ccdab 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -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();
///
diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs
index b3178064505..6b075e7ac0e 100644
--- a/src/liballoc/tests/str.rs
+++ b/src/liballoc/tests/str.rs
@@ -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);
diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs
index 0e25da5bd30..9cfde5dcc73 100644
--- a/src/liballoc/tests/vec.rs
+++ b/src/liballoc/tests/vec.rs
@@ -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;
@@ -966,5 +965,3 @@ fn drain_filter_complex() {
assert_eq!(vec, vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19]);
}
}
-
-
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index cf34e195dea..5aca199cf40 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -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));
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
index bca4dad220f..d648099d74d 100644
--- a/src/librustc/lint/mod.rs
+++ b/src/librustc/lint/mod.rs
@@ -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;
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index e3ce403f3c1..915383d8189 100644
--- a/src/librustdoc/clean/cfg.rs
+++ b/src/librustdoc/clean/cfg.rs
@@ -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;
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index edd01a66075..228bd7a0330 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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;
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index 200264a2583..96d719c528c 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -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}"`
@@ -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]
diff --git a/src/test/ui/deref-suggestion.stderr b/src/test/ui/deref-suggestion.stderr
index 5ad9c19fa8c..3ed3297e05e 100644
--- a/src/test/ui/deref-suggestion.stderr
+++ b/src/test/ui/deref-suggestion.stderr
@@ -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