]> git.lizzy.rs Git - rust.git/commitdiff
Remove unused AsciiExt imports and fix tests related to ascii methods
authorLukas Kalbertodt <lukas.kalbertodt@gmail.com>
Mon, 2 Oct 2017 07:50:36 +0000 (09:50 +0200)
committerLukas Kalbertodt <lukas.kalbertodt@gmail.com>
Fri, 3 Nov 2017 20:27:40 +0000 (21:27 +0100)
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.

12 files changed:
src/liballoc/benches/str.rs
src/liballoc/borrow.rs
src/liballoc/str.rs
src/liballoc/string.rs
src/liballoc/tests/str.rs
src/liballoc/tests/vec.rs
src/liballoc/vec.rs
src/librustc/lint/mod.rs
src/librustdoc/clean/cfg.rs
src/librustdoc/html/render.rs
src/libstd/ascii.rs
src/test/ui/deref-suggestion.stderr

index fc4063fae927754353d5e736099f0a365b0dd2d7..38c94d4d8b5f36a64739c7b2d4192be4876b7e5d 100644 (file)
@@ -272,15 +272,12 @@ mod $name {
 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())
 });
 
index a662e4b1f4f931de28292c8ed094f559e4d0b031..e8aff0998715726bc21c4908b790a71f19400535 100644 (file)
@@ -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");
index 2c257b8c736787c94c799b42592ec2a409b605a5..b75ecb6ea51cf8ebc44aab4889f5c0d4e5847595 100644 (file)
@@ -390,8 +390,6 @@ pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> {
     /// # 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 @@ pub fn split_at(&self, mid: usize) -> (&str, &str) {
     /// Basic usage:
     ///
     /// ```
-    /// use std::ascii::AsciiExt;
-    ///
     /// let mut s = "Per Martin-Löf".to_string();
     /// {
     ///     let (first, last) = s.split_at_mut(3);
index 6d0bb264df1863b50264b1f73df9a6d6d683dbe0..25fcc1ccdab589e8c774572c82098967ec58a563 100644 (file)
@@ -773,8 +773,6 @@ pub fn as_str(&self) -> &str {
     /// Basic usage:
     ///
     /// ```
-    /// use std::ascii::AsciiExt;
-    ///
     /// let mut s = String::from("foobar");
     /// let s_mut_str = s.as_mut_str();
     ///
index b3178064505e8683f0bbeacd77b01b3c36ccca89..6b075e7ac0e0d0f47f1fbd776973306e048abcf6 100644 (file)
@@ -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);
index 0e25da5bd3077f099034e6deaaabdba5e7adf5ac..9cfde5dcc73c8433b0f37f030a30b1b0b6fbb9b0 100644 (file)
@@ -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]);
     }
 }
-
-
index cf34e195dea76fe1d8262d412eab2823cb965e87..5aca199cf40c068896632a566ab7bd30e0eed334 100644 (file)
@@ -853,8 +853,6 @@ pub fn dedup_by_key<F, K>(&mut self, mut key: F) where F: FnMut(&mut T) -> K, K:
     /// # 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));
index bca4dad220fcdcb978b4d1fcbace544dec3541ee..d648099d74d365e476619744d1462c40d0538448 100644 (file)
@@ -38,6 +38,7 @@
 use hir::intravisit::{self, FnKind};
 use hir;
 use session::Session;
+#[cfg(stage0)]
 use std::ascii::AsciiExt;
 use std::hash;
 use syntax::ast;
index e3ce403f3c17baa60ded8e1321678f41de939a30..915383d8189e0db2a797150a318453e9723d7a22 100644 (file)
@@ -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;
index edd01a66075b0b62d128c5ca05f9b638b27dc1e0..228bd7a033090a8202f24e92d712c52fbe902a41 100644 (file)
@@ -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;
index 200264a25834d6dddf049786a4046ca8cee0e912..96d719c528c109bf5fad03ef6a48ad897ce36b4a 100644 (file)
@@ -38,8 +38,8 @@
 /// ```
 /// 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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 #[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]
index 5ad9c19fa8cc2b2e366ad8f7fa1b747f4714a366..3ed3297e05ed95a5976c1795ce3deccb9fe9e987 100644 (file)
@@ -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