From f09f62f62c401a42bf338a23f8721c7f5a28a800 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 10:34:36 +0100 Subject: [PATCH] liballoc: adjust abolute imports + more import fixes. --- src/liballoc/lib.rs | 2 +- src/liballoc/raw_vec.rs | 2 +- src/liballoc/rc.rs | 3 +-- src/liballoc/slice.rs | 4 +--- src/liballoc/string.rs | 2 +- src/liballoc/sync.rs | 3 +-- src/liballoc/tests/btree/map.rs | 2 +- src/liballoc/tests/str.rs | 4 ++-- src/liballoc/tests/string.rs | 4 ++-- src/liballoc/tests/vec.rs | 2 +- src/liballoc/vec.rs | 12 +++--------- 11 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5165a7ca5a8..5d69b100547 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -165,5 +165,5 @@ mod boxed { #[cfg(not(test))] mod std { - pub use core::ops; // RangeFull + pub use core::ops; // RangeFull } diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 92d482b1f05..016185791ed 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -736,7 +736,7 @@ fn drop(&mut self) { #[inline] fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> { - if mem::size_of::() < 8 && alloc_size > ::core::isize::MAX as usize { + if mem::size_of::() < 8 && alloc_size > core::isize::MAX as usize { Err(CapacityOverflow) } else { Ok(()) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 720ac4b630a..c24e2163839 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -244,6 +244,7 @@ ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}, pin::Pin, ptr::{self, NonNull}, + slice::from_raw_parts_mut, convert::From, usize, }; @@ -768,8 +769,6 @@ struct Guard { impl Drop for Guard { fn drop(&mut self) { - use core::slice::from_raw_parts_mut; - unsafe { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 1cee3aa415b..771d8f5d347 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -141,13 +141,11 @@ // `test_permutations` test mod hack { use core::mem; - use crate::boxed::Box; + use crate::{boxed::Box, vec::Vec}; #[cfg(test)] use crate::string::ToString; - use crate::vec::Vec; - pub fn into_vec(mut b: Box<[T]>) -> Vec { unsafe { let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len()); diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index e9da10b3597..95f6b28a168 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2165,7 +2165,7 @@ pub trait ToString { impl ToString for T { #[inline] default fn to_string(&self) -> String { - use core::fmt::Write; + use fmt::Write; let mut buf = String::new(); buf.write_fmt(format_args!("{}", self)) .expect("a Display implementation returned an error unexpectedly"); diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2a4b3113bfe..5e7a26132cb 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -24,6 +24,7 @@ hash::{Hash, Hasher}, isize, usize, convert::From, + slice::from_raw_parts_mut, }; use crate::{ @@ -677,8 +678,6 @@ struct Guard { impl Drop for Guard { fn drop(&mut self) { - use core::slice::from_raw_parts_mut; - unsafe { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index 33f65980784..6859b0138b5 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -200,7 +200,7 @@ fn check<'a, L, R>(lhs: L, rhs: R) #[test] fn test_range_inclusive_max_value() { - let max = ::std::usize::MAX; + let max = std::usize::MAX; let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect(); assert_eq!(map.range(max..=max).collect::>(), &[(&max, &0)]); diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 583e616bf6d..28e021c741e 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -1070,7 +1070,7 @@ fn test_rev_iterator() { #[test] fn test_chars_decoding() { let mut bytes = [0; 4]; - for c in (0..0x110000).filter_map(::std::char::from_u32) { + for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().next() { panic!("character {:x}={} does not decode correctly", c as u32, c); @@ -1081,7 +1081,7 @@ fn test_chars_decoding() { #[test] fn test_chars_rev_decoding() { let mut bytes = [0; 4]; - for c in (0..0x110000).filter_map(::std::char::from_u32) { + for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().rev().next() { panic!("character {:x}={} does not decode correctly", c as u32, c); diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 9e4ffb5be9d..14f70fdf303 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -23,7 +23,7 @@ fn into_cow(self) -> Cow<'a, str> { #[test] fn test_from_str() { - let owned: Option<::std::string::String> = "string".parse().ok(); + let owned: Option = "string".parse().ok(); assert_eq!(owned.as_ref().map(|s| &**s), Some("string")); } @@ -124,7 +124,7 @@ fn test_from_utf16() { let s_as_utf16 = s.encode_utf16().collect::>(); let u_as_string = String::from_utf16(&u).unwrap(); - assert!(::core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok())); + assert!(core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok())); assert_eq!(s_as_utf16, u); assert_eq!(u_as_string, s); diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 473d41d483e..b65c68d51a5 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -640,7 +640,7 @@ fn test_splice_unbounded() { fn test_splice_forget() { let mut v = vec![1, 2, 3, 4, 5]; let a = [10, 11, 12]; - ::std::mem::forget(v.splice(2..4, a.iter().cloned())); + std::mem::forget(v.splice(2..4, a.iter().cloned())); assert_eq!(v, &[1, 2]); } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 69fcd87dae6..2ef1497ade7 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -70,7 +70,7 @@ Index, IndexMut, RangeBounds, }, ptr::{self, NonNull}, - slice, + slice::{self, SliceIndex}, }; use crate::{ @@ -1672,10 +1672,7 @@ fn hash(&self, state: &mut H) { message="vector indices are of type `usize` or ranges of `usize`", label="vector indices are of type `usize` or ranges of `usize`", )] -impl Index for Vec -where - I: ::core::slice::SliceIndex<[T]>, -{ +impl> Index for Vec { type Output = I::Output; #[inline] @@ -1689,10 +1686,7 @@ fn index(&self, index: I) -> &Self::Output { message="vector indices are of type `usize` or ranges of `usize`", label="vector indices are of type `usize` or ranges of `usize`", )] -impl IndexMut for Vec -where - I: ::core::slice::SliceIndex<[T]>, -{ +impl> IndexMut for Vec { #[inline] fn index_mut(&mut self, index: I) -> &mut Self::Output { IndexMut::index_mut(&mut **self, index) -- 2.44.0