mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
liballoc: adjust abolute imports + more import fixes.
This commit is contained in:
parent
7693e3e666
commit
f09f62f62c
@ -165,5 +165,5 @@ pub mod vec;
|
||||
|
||||
#[cfg(not(test))]
|
||||
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]
|
||||
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)
|
||||
} else {
|
||||
Ok(())
|
||||
|
@ -244,6 +244,7 @@ use core::{
|
||||
ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn},
|
||||
pin::Pin,
|
||||
ptr::{self, NonNull},
|
||||
slice::from_raw_parts_mut,
|
||||
convert::From,
|
||||
usize,
|
||||
};
|
||||
@ -768,8 +769,6 @@ impl<T: Clone> RcFromSlice<T> for Rc<[T]> {
|
||||
|
||||
impl<T> Drop for Guard<T> {
|
||||
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);
|
||||
|
@ -141,13 +141,11 @@ pub use self::hack::to_vec;
|
||||
// `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<T>(mut b: Box<[T]>) -> Vec<T> {
|
||||
unsafe {
|
||||
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 {
|
||||
#[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");
|
||||
|
@ -24,6 +24,7 @@ use core::{
|
||||
hash::{Hash, Hasher},
|
||||
isize, usize,
|
||||
convert::From,
|
||||
slice::from_raw_parts_mut,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@ -677,8 +678,6 @@ impl<T: Clone> ArcFromSlice<T> for Arc<[T]> {
|
||||
|
||||
impl<T> Drop for Guard<T> {
|
||||
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);
|
||||
|
@ -200,7 +200,7 @@ fn test_range_inclusive() {
|
||||
|
||||
#[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::<Vec<_>>(), &[(&max, &0)]);
|
||||
|
@ -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);
|
||||
|
@ -23,7 +23,7 @@ impl<'a> IntoCow<'a, str> for &'a str {
|
||||
|
||||
#[test]
|
||||
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"));
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ fn test_from_utf16() {
|
||||
let s_as_utf16 = s.encode_utf16().collect::<Vec<u16>>();
|
||||
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);
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ use core::{
|
||||
Index, IndexMut, RangeBounds,
|
||||
},
|
||||
ptr::{self, NonNull},
|
||||
slice,
|
||||
slice::{self, SliceIndex},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@ -1672,10 +1672,7 @@ impl<T: Hash> Hash for Vec<T> {
|
||||
message="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>
|
||||
where
|
||||
I: ::core::slice::SliceIndex<[T]>,
|
||||
{
|
||||
impl<T, I: SliceIndex<[T]>> Index<I> for Vec<T> {
|
||||
type Output = I::Output;
|
||||
|
||||
#[inline]
|
||||
@ -1689,10 +1686,7 @@ where
|
||||
message="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>
|
||||
where
|
||||
I: ::core::slice::SliceIndex<[T]>,
|
||||
{
|
||||
impl<T, I: SliceIndex<[T]>> IndexMut<I> for Vec<T> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: I) -> &mut Self::Output {
|
||||
IndexMut::index_mut(&mut **self, index)
|
||||
|
Loading…
Reference in New Issue
Block a user