Skip to content

Commit f09f62f

Browse files
committed
liballoc: adjust abolute imports + more import fixes.
1 parent 7693e3e commit f09f62f

File tree

11 files changed

+15
-25
lines changed

11 files changed

+15
-25
lines changed

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ pub mod vec;
165165

166166
#[cfg(not(test))]
167167
mod std {
168-
pub use core::ops; // RangeFull
168+
pub use core::ops; // RangeFull
169169
}

src/liballoc/raw_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec<T, A> {
736736

737737
#[inline]
738738
fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> {
739-
if mem::size_of::<usize>() < 8 && alloc_size > ::core::isize::MAX as usize {
739+
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
740740
Err(CapacityOverflow)
741741
} else {
742742
Ok(())

src/liballoc/rc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ use core::{
244244
ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn},
245245
pin::Pin,
246246
ptr::{self, NonNull},
247+
slice::from_raw_parts_mut,
247248
convert::From,
248249
usize,
249250
};
@@ -768,8 +769,6 @@ impl<T: Clone> RcFromSlice<T> for Rc<[T]> {
768769

769770
impl<T> Drop for Guard<T> {
770771
fn drop(&mut self) {
771-
use core::slice::from_raw_parts_mut;
772-
773772
unsafe {
774773
let slice = from_raw_parts_mut(self.elems, self.n_elems);
775774
ptr::drop_in_place(slice);

src/liballoc/slice.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,11 @@ pub use self::hack::to_vec;
141141
// `test_permutations` test
142142
mod hack {
143143
use core::mem;
144-
use crate::boxed::Box;
144+
use crate::{boxed::Box, vec::Vec};
145145

146146
#[cfg(test)]
147147
use crate::string::ToString;
148148

149-
use crate::vec::Vec;
150-
151149
pub fn into_vec<T>(mut b: Box<[T]>) -> Vec<T> {
152150
unsafe {
153151
let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len());

src/liballoc/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ pub trait ToString {
21652165
impl<T: fmt::Display + ?Sized> ToString for T {
21662166
#[inline]
21672167
default fn to_string(&self) -> String {
2168-
use core::fmt::Write;
2168+
use fmt::Write;
21692169
let mut buf = String::new();
21702170
buf.write_fmt(format_args!("{}", self))
21712171
.expect("a Display implementation returned an error unexpectedly");

src/liballoc/sync.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use core::{
2424
hash::{Hash, Hasher},
2525
isize, usize,
2626
convert::From,
27+
slice::from_raw_parts_mut,
2728
};
2829

2930
use crate::{
@@ -677,8 +678,6 @@ impl<T: Clone> ArcFromSlice<T> for Arc<[T]> {
677678

678679
impl<T> Drop for Guard<T> {
679680
fn drop(&mut self) {
680-
use core::slice::from_raw_parts_mut;
681-
682681
unsafe {
683682
let slice = from_raw_parts_mut(self.elems, self.n_elems);
684683
ptr::drop_in_place(slice);

src/liballoc/tests/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn test_range_inclusive() {
200200

201201
#[test]
202202
fn test_range_inclusive_max_value() {
203-
let max = ::std::usize::MAX;
203+
let max = std::usize::MAX;
204204
let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect();
205205

206206
assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);

src/liballoc/tests/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ fn test_rev_iterator() {
10701070
#[test]
10711071
fn test_chars_decoding() {
10721072
let mut bytes = [0; 4];
1073-
for c in (0..0x110000).filter_map(::std::char::from_u32) {
1073+
for c in (0..0x110000).filter_map(std::char::from_u32) {
10741074
let s = c.encode_utf8(&mut bytes);
10751075
if Some(c) != s.chars().next() {
10761076
panic!("character {:x}={} does not decode correctly", c as u32, c);
@@ -1081,7 +1081,7 @@ fn test_chars_decoding() {
10811081
#[test]
10821082
fn test_chars_rev_decoding() {
10831083
let mut bytes = [0; 4];
1084-
for c in (0..0x110000).filter_map(::std::char::from_u32) {
1084+
for c in (0..0x110000).filter_map(std::char::from_u32) {
10851085
let s = c.encode_utf8(&mut bytes);
10861086
if Some(c) != s.chars().rev().next() {
10871087
panic!("character {:x}={} does not decode correctly", c as u32, c);

src/liballoc/tests/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'a> IntoCow<'a, str> for &'a str {
2323

2424
#[test]
2525
fn test_from_str() {
26-
let owned: Option<::std::string::String> = "string".parse().ok();
26+
let owned: Option<std::string::String> = "string".parse().ok();
2727
assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
2828
}
2929

@@ -124,7 +124,7 @@ fn test_from_utf16() {
124124
let s_as_utf16 = s.encode_utf16().collect::<Vec<u16>>();
125125
let u_as_string = String::from_utf16(&u).unwrap();
126126

127-
assert!(::core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok()));
127+
assert!(core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok()));
128128
assert_eq!(s_as_utf16, u);
129129

130130
assert_eq!(u_as_string, s);

src/liballoc/tests/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ fn test_splice_unbounded() {
640640
fn test_splice_forget() {
641641
let mut v = vec![1, 2, 3, 4, 5];
642642
let a = [10, 11, 12];
643-
::std::mem::forget(v.splice(2..4, a.iter().cloned()));
643+
std::mem::forget(v.splice(2..4, a.iter().cloned()));
644644
assert_eq!(v, &[1, 2]);
645645
}
646646

src/liballoc/vec.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use core::{
7070
Index, IndexMut, RangeBounds,
7171
},
7272
ptr::{self, NonNull},
73-
slice,
73+
slice::{self, SliceIndex},
7474
};
7575

7676
use crate::{
@@ -1672,10 +1672,7 @@ impl<T: Hash> Hash for Vec<T> {
16721672
message="vector indices are of type `usize` or ranges of `usize`",
16731673
label="vector indices are of type `usize` or ranges of `usize`",
16741674
)]
1675-
impl<T, I> Index<I> for Vec<T>
1676-
where
1677-
I: ::core::slice::SliceIndex<[T]>,
1678-
{
1675+
impl<T, I: SliceIndex<[T]>> Index<I> for Vec<T> {
16791676
type Output = I::Output;
16801677

16811678
#[inline]
@@ -1689,10 +1686,7 @@ where
16891686
message="vector indices are of type `usize` or ranges of `usize`",
16901687
label="vector indices are of type `usize` or ranges of `usize`",
16911688
)]
1692-
impl<T, I> IndexMut<I> for Vec<T>
1693-
where
1694-
I: ::core::slice::SliceIndex<[T]>,
1695-
{
1689+
impl<T, I: SliceIndex<[T]>> IndexMut<I> for Vec<T> {
16961690
#[inline]
16971691
fn index_mut(&mut self, index: I) -> &mut Self::Output {
16981692
IndexMut::index_mut(&mut **self, index)

0 commit comments

Comments
 (0)