liballoc: adjust abolute imports + more import fixes.
This commit is contained in:
parent
7693e3e666
commit
f09f62f62c
11 changed files with 15 additions and 25 deletions
|
@ -165,5 +165,5 @@ pub mod vec;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
mod std {
|
mod std {
|
||||||
pub use core::ops; // RangeFull
|
pub use core::ops; // RangeFull
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,7 +736,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec<T, A> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> {
|
fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> {
|
||||||
if mem::size_of::<usize>() < 8 && alloc_size > ::core::isize::MAX as usize {
|
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
|
||||||
Err(CapacityOverflow)
|
Err(CapacityOverflow)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -244,6 +244,7 @@ use core::{
|
||||||
ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn},
|
ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
ptr::{self, NonNull},
|
ptr::{self, NonNull},
|
||||||
|
slice::from_raw_parts_mut,
|
||||||
convert::From,
|
convert::From,
|
||||||
usize,
|
usize,
|
||||||
};
|
};
|
||||||
|
@ -768,8 +769,6 @@ impl<T: Clone> RcFromSlice<T> for Rc<[T]> {
|
||||||
|
|
||||||
impl<T> Drop for Guard<T> {
|
impl<T> Drop for Guard<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
use core::slice::from_raw_parts_mut;
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let slice = from_raw_parts_mut(self.elems, self.n_elems);
|
let slice = from_raw_parts_mut(self.elems, self.n_elems);
|
||||||
ptr::drop_in_place(slice);
|
ptr::drop_in_place(slice);
|
||||||
|
|
|
@ -141,13 +141,11 @@ pub use self::hack::to_vec;
|
||||||
// `test_permutations` test
|
// `test_permutations` test
|
||||||
mod hack {
|
mod hack {
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use crate::boxed::Box;
|
use crate::{boxed::Box, vec::Vec};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use crate::string::ToString;
|
use crate::string::ToString;
|
||||||
|
|
||||||
use crate::vec::Vec;
|
|
||||||
|
|
||||||
pub fn into_vec<T>(mut b: Box<[T]>) -> Vec<T> {
|
pub fn into_vec<T>(mut b: Box<[T]>) -> Vec<T> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len());
|
let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len());
|
||||||
|
|
|
@ -2165,7 +2165,7 @@ pub trait ToString {
|
||||||
impl<T: fmt::Display + ?Sized> ToString for T {
|
impl<T: fmt::Display + ?Sized> ToString for T {
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn to_string(&self) -> String {
|
default fn to_string(&self) -> String {
|
||||||
use core::fmt::Write;
|
use fmt::Write;
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
buf.write_fmt(format_args!("{}", self))
|
buf.write_fmt(format_args!("{}", self))
|
||||||
.expect("a Display implementation returned an error unexpectedly");
|
.expect("a Display implementation returned an error unexpectedly");
|
||||||
|
|
|
@ -24,6 +24,7 @@ use core::{
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
isize, usize,
|
isize, usize,
|
||||||
convert::From,
|
convert::From,
|
||||||
|
slice::from_raw_parts_mut,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -677,8 +678,6 @@ impl<T: Clone> ArcFromSlice<T> for Arc<[T]> {
|
||||||
|
|
||||||
impl<T> Drop for Guard<T> {
|
impl<T> Drop for Guard<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
use core::slice::from_raw_parts_mut;
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let slice = from_raw_parts_mut(self.elems, self.n_elems);
|
let slice = from_raw_parts_mut(self.elems, self.n_elems);
|
||||||
ptr::drop_in_place(slice);
|
ptr::drop_in_place(slice);
|
||||||
|
|
|
@ -200,7 +200,7 @@ fn test_range_inclusive() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_range_inclusive_max_value() {
|
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();
|
let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect();
|
||||||
|
|
||||||
assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);
|
assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ fn test_rev_iterator() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chars_decoding() {
|
fn test_chars_decoding() {
|
||||||
let mut bytes = [0; 4];
|
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);
|
let s = c.encode_utf8(&mut bytes);
|
||||||
if Some(c) != s.chars().next() {
|
if Some(c) != s.chars().next() {
|
||||||
panic!("character {:x}={} does not decode correctly", c as u32, c);
|
panic!("character {:x}={} does not decode correctly", c as u32, c);
|
||||||
|
@ -1081,7 +1081,7 @@ fn test_chars_decoding() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chars_rev_decoding() {
|
fn test_chars_rev_decoding() {
|
||||||
let mut bytes = [0; 4];
|
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);
|
let s = c.encode_utf8(&mut bytes);
|
||||||
if Some(c) != s.chars().rev().next() {
|
if Some(c) != s.chars().rev().next() {
|
||||||
panic!("character {:x}={} does not decode correctly", c as u32, c);
|
panic!("character {:x}={} does not decode correctly", c as u32, c);
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl<'a> IntoCow<'a, str> for &'a str {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_str() {
|
fn test_from_str() {
|
||||||
let owned: Option<::std::string::String> = "string".parse().ok();
|
let owned: Option<std::string::String> = "string".parse().ok();
|
||||||
assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
|
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::<Vec<u16>>();
|
let s_as_utf16 = s.encode_utf16().collect::<Vec<u16>>();
|
||||||
let u_as_string = String::from_utf16(&u).unwrap();
|
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!(s_as_utf16, u);
|
||||||
|
|
||||||
assert_eq!(u_as_string, s);
|
assert_eq!(u_as_string, s);
|
||||||
|
|
|
@ -640,7 +640,7 @@ fn test_splice_unbounded() {
|
||||||
fn test_splice_forget() {
|
fn test_splice_forget() {
|
||||||
let mut v = vec![1, 2, 3, 4, 5];
|
let mut v = vec![1, 2, 3, 4, 5];
|
||||||
let a = [10, 11, 12];
|
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]);
|
assert_eq!(v, &[1, 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ use core::{
|
||||||
Index, IndexMut, RangeBounds,
|
Index, IndexMut, RangeBounds,
|
||||||
},
|
},
|
||||||
ptr::{self, NonNull},
|
ptr::{self, NonNull},
|
||||||
slice,
|
slice::{self, SliceIndex},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -1672,10 +1672,7 @@ impl<T: Hash> Hash for Vec<T> {
|
||||||
message="vector indices are of type `usize` or ranges of `usize`",
|
message="vector indices are of type `usize` or ranges of `usize`",
|
||||||
label="vector indices are of type `usize` or ranges of `usize`",
|
label="vector indices are of type `usize` or ranges of `usize`",
|
||||||
)]
|
)]
|
||||||
impl<T, I> Index<I> for Vec<T>
|
impl<T, I: SliceIndex<[T]>> Index<I> for Vec<T> {
|
||||||
where
|
|
||||||
I: ::core::slice::SliceIndex<[T]>,
|
|
||||||
{
|
|
||||||
type Output = I::Output;
|
type Output = I::Output;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1689,10 +1686,7 @@ where
|
||||||
message="vector indices are of type `usize` or ranges of `usize`",
|
message="vector indices are of type `usize` or ranges of `usize`",
|
||||||
label="vector indices are of type `usize` or ranges of `usize`",
|
label="vector indices are of type `usize` or ranges of `usize`",
|
||||||
)]
|
)]
|
||||||
impl<T, I> IndexMut<I> for Vec<T>
|
impl<T, I: SliceIndex<[T]>> IndexMut<I> for Vec<T> {
|
||||||
where
|
|
||||||
I: ::core::slice::SliceIndex<[T]>,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn index_mut(&mut self, index: I) -> &mut Self::Output {
|
fn index_mut(&mut self, index: I) -> &mut Self::Output {
|
||||||
IndexMut::index_mut(&mut **self, index)
|
IndexMut::index_mut(&mut **self, index)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue