Skip to content

Commit d5c7237

Browse files
authored
Rollup merge of rust-lang#110244 - kadiwa4:unnecessary_imports, r=JohnTitor
Remove some unneeded imports / qualified paths Continuation of rust-lang#105537.
2 parents d1c480f + ad2b34d commit d5c7237

File tree

55 files changed

+64
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+64
-135
lines changed

library/alloc/benches/btree/map.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::collections::BTreeMap;
2-
use std::iter::Iterator;
32
use std::ops::RangeBounds;
43
use std::vec::Vec;
54

library/alloc/benches/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rand::RngCore;
2-
use std::iter::{repeat, FromIterator};
2+
use std::iter::repeat;
33
use test::{black_box, Bencher};
44

55
#[bench]

library/alloc/src/boxed.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,13 @@ use core::any::Any;
150150
use core::async_iter::AsyncIterator;
151151
use core::borrow;
152152
use core::cmp::Ordering;
153-
use core::convert::{From, TryFrom};
154153
use core::error::Error;
155154
use core::fmt;
156155
use core::future::Future;
157156
use core::hash::{Hash, Hasher};
158-
#[cfg(not(no_global_oom_handling))]
159-
use core::iter::FromIterator;
160-
use core::iter::{FusedIterator, Iterator};
157+
use core::iter::FusedIterator;
161158
use core::marker::Tuple;
162-
use core::marker::{Unpin, Unsize};
159+
use core::marker::Unsize;
163160
use core::mem;
164161
use core::ops::{
165162
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,

library/alloc/src/collections/binary_heap/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
#![stable(feature = "rust1", since = "1.0.0")]
145145

146146
use core::fmt;
147-
use core::iter::{FromIterator, FusedIterator, InPlaceIterable, SourceIter, TrustedLen};
147+
use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedLen};
148148
use core::mem::{self, swap, ManuallyDrop};
149149
use core::num::NonZeroUsize;
150150
use core::ops::{Deref, DerefMut};
@@ -263,7 +263,6 @@ mod tests;
263263
/// more detailed analysis.
264264
///
265265
/// [`core::cmp::Reverse`]: core::cmp::Reverse
266-
/// [`Ord`]: core::cmp::Ord
267266
/// [`Cell`]: core::cell::Cell
268267
/// [`RefCell`]: core::cell::RefCell
269268
/// [push]: BinaryHeap::push
@@ -1418,7 +1417,6 @@ impl<T> FusedIterator for Iter<'_, T> {}
14181417
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
14191418
///
14201419
/// [`into_iter`]: BinaryHeap::into_iter
1421-
/// [`IntoIterator`]: core::iter::IntoIterator
14221420
#[stable(feature = "rust1", since = "1.0.0")]
14231421
#[derive(Clone)]
14241422
pub struct IntoIter<T> {

library/alloc/src/collections/btree/map.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::borrow::Borrow;
33
use core::cmp::Ordering;
44
use core::fmt::{self, Debug};
55
use core::hash::{Hash, Hasher};
6-
use core::iter::{FromIterator, FusedIterator};
6+
use core::iter::FusedIterator;
77
use core::marker::PhantomData;
88
use core::mem::{self, ManuallyDrop};
99
use core::ops::{Bound, Index, RangeBounds};
@@ -420,7 +420,6 @@ impl<'a, K: 'a, V: 'a> Default for IterMut<'a, K, V> {
420420
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
421421
///
422422
/// [`into_iter`]: IntoIterator::into_iter
423-
/// [`IntoIterator`]: core::iter::IntoIterator
424423
#[stable(feature = "rust1", since = "1.0.0")]
425424
#[rustc_insignificant_dtor]
426425
pub struct IntoIter<
@@ -650,7 +649,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
650649
#[stable(feature = "rust1", since = "1.0.0")]
651650
pub fn clear(&mut self) {
652651
// avoid moving the allocator
653-
mem::drop(BTreeMap {
652+
drop(BTreeMap {
654653
root: mem::replace(&mut self.root, None),
655654
length: mem::replace(&mut self.length, 0),
656655
alloc: self.alloc.clone(),

library/alloc/src/collections/btree/map/tests.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use crate::testing::ord_chaos::{Cyclic3, Governed, Governor};
99
use crate::testing::rng::DeterministicRng;
1010
use crate::vec::Vec;
1111
use std::cmp::Ordering;
12-
use std::convert::TryFrom;
13-
use std::iter::{self, FromIterator};
12+
use std::iter;
1413
use std::mem;
1514
use std::ops::Bound::{self, Excluded, Included, Unbounded};
1615
use std::ops::RangeBounds;

library/alloc/src/collections/btree/set.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::cmp::Ordering::{self, Equal, Greater, Less};
44
use core::cmp::{max, min};
55
use core::fmt::{self, Debug};
66
use core::hash::{Hash, Hasher};
7-
use core::iter::{FromIterator, FusedIterator, Peekable};
7+
use core::iter::{FusedIterator, Peekable};
88
use core::mem::ManuallyDrop;
99
use core::ops::{BitAnd, BitOr, BitXor, RangeBounds, Sub};
1010

@@ -30,7 +30,6 @@ use crate::alloc::{Allocator, Global};
3030
/// Iterators returned by [`BTreeSet::iter`] produce their items in order, and take worst-case
3131
/// logarithmic and amortized constant time per item returned.
3232
///
33-
/// [`Ord`]: core::cmp::Ord
3433
/// [`Cell`]: core::cell::Cell
3534
/// [`RefCell`]: core::cell::RefCell
3635
///
@@ -147,7 +146,6 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
147146
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
148147
///
149148
/// [`into_iter`]: BTreeSet#method.into_iter
150-
/// [`IntoIterator`]: core::iter::IntoIterator
151149
#[stable(feature = "rust1", since = "1.0.0")]
152150
#[derive(Debug)]
153151
pub struct IntoIter<

library/alloc/src/collections/btree/set/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::testing::rng::DeterministicRng;
44
use crate::vec::Vec;
55
use std::cmp::Ordering;
66
use std::hash::{Hash, Hasher};
7-
use std::iter::FromIterator;
87
use std::ops::Bound::{Excluded, Included};
98
use std::panic::{catch_unwind, AssertUnwindSafe};
109

library/alloc/src/collections/linked_list.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use core::cmp::Ordering;
1616
use core::fmt;
1717
use core::hash::{Hash, Hasher};
18-
use core::iter::{FromIterator, FusedIterator};
18+
use core::iter::FusedIterator;
1919
use core::marker::PhantomData;
2020
use core::mem;
2121
use core::ptr::NonNull;
@@ -130,7 +130,6 @@ impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
130130
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
131131
///
132132
/// [`into_iter`]: LinkedList::into_iter
133-
/// [`IntoIterator`]: core::iter::IntoIterator
134133
#[derive(Clone)]
135134
#[stable(feature = "rust1", since = "1.0.0")]
136135
pub struct IntoIter<T> {

library/alloc/src/collections/vec_deque/into_iter.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use super::VecDeque;
1212
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
1313
///
1414
/// [`into_iter`]: VecDeque::into_iter
15-
/// [`IntoIterator`]: core::iter::IntoIterator
1615
#[derive(Clone)]
1716
#[stable(feature = "rust1", since = "1.0.0")]
1817
pub struct IntoIter<

library/alloc/src/collections/vec_deque/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use core::cmp::{self, Ordering};
1111
use core::fmt;
1212
use core::hash::{Hash, Hasher};
13-
use core::iter::{repeat_n, repeat_with, ByRefSized, FromIterator};
13+
use core::iter::{repeat_n, repeat_with, ByRefSized};
1414
use core::mem::{ManuallyDrop, SizedTypeProperties};
1515
use core::ops::{Index, IndexMut, Range, RangeBounds};
1616
use core::ptr;

library/alloc/src/raw_vec.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use core::alloc::LayoutError;
44
use core::cmp;
55
use core::intrinsics;
66
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
7-
use core::ops::Drop;
87
use core::ptr::{self, NonNull, Unique};
98
use core::slice;
109

library/alloc/src/rc.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//! [`Rc`] uses non-atomic reference counting. This means that overhead is very
1717
//! low, but an [`Rc`] cannot be sent between threads, and consequently [`Rc`]
18-
//! does not implement [`Send`][send]. As a result, the Rust compiler
18+
//! does not implement [`Send`]. As a result, the Rust compiler
1919
//! will check *at compile time* that you are not sending [`Rc`]s between
2020
//! threads. If you need multi-threaded, atomic reference counting, use
2121
//! [`sync::Arc`][arc].
@@ -232,7 +232,6 @@
232232
//! [clone]: Clone::clone
233233
//! [`Cell`]: core::cell::Cell
234234
//! [`RefCell`]: core::cell::RefCell
235-
//! [send]: core::marker::Send
236235
//! [arc]: crate::sync::Arc
237236
//! [`Deref`]: core::ops::Deref
238237
//! [downgrade]: Rc::downgrade
@@ -251,13 +250,12 @@ use core::any::Any;
251250
use core::borrow;
252251
use core::cell::Cell;
253252
use core::cmp::Ordering;
254-
use core::convert::{From, TryFrom};
255253
use core::fmt;
256254
use core::hash::{Hash, Hasher};
257255
use core::intrinsics::abort;
258256
#[cfg(not(no_global_oom_handling))]
259257
use core::iter;
260-
use core::marker::{self, PhantomData, Unpin, Unsize};
258+
use core::marker::{PhantomData, Unsize};
261259
#[cfg(not(no_global_oom_handling))]
262260
use core::mem::size_of_val;
263261
use core::mem::{self, align_of_val_raw, forget};
@@ -321,15 +319,15 @@ pub struct Rc<T: ?Sized> {
321319
}
322320

323321
#[stable(feature = "rust1", since = "1.0.0")]
324-
impl<T: ?Sized> !marker::Send for Rc<T> {}
322+
impl<T: ?Sized> !Send for Rc<T> {}
325323

326324
// Note that this negative impl isn't strictly necessary for correctness,
327325
// as `Rc` transitively contains a `Cell`, which is itself `!Sync`.
328326
// However, given how important `Rc`'s `!Sync`-ness is,
329327
// having an explicit negative impl is nice for documentation purposes
330328
// and results in nicer error messages.
331329
#[stable(feature = "rust1", since = "1.0.0")]
332-
impl<T: ?Sized> !marker::Sync for Rc<T> {}
330+
impl<T: ?Sized> !Sync for Rc<T> {}
333331

334332
#[stable(feature = "catch_unwind", since = "1.9.0")]
335333
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for Rc<T> {}
@@ -1060,7 +1058,7 @@ impl<T: ?Sized> Rc<T> {
10601058
#[inline]
10611059
#[stable(feature = "rc_mutate_strong_count", since = "1.53.0")]
10621060
pub unsafe fn decrement_strong_count(ptr: *const T) {
1063-
unsafe { mem::drop(Rc::from_raw(ptr)) };
1061+
unsafe { drop(Rc::from_raw(ptr)) };
10641062
}
10651063

10661064
/// Returns `true` if there are no other `Rc` or [`Weak`] pointers to
@@ -1496,7 +1494,7 @@ impl<T> Rc<[T]> {
14961494
///
14971495
/// Behavior is undefined should the size be wrong.
14981496
#[cfg(not(no_global_oom_handling))]
1499-
unsafe fn from_iter_exact(iter: impl iter::Iterator<Item = T>, len: usize) -> Rc<[T]> {
1497+
unsafe fn from_iter_exact(iter: impl Iterator<Item = T>, len: usize) -> Rc<[T]> {
15001498
// Panic guard while cloning T elements.
15011499
// In the event of a panic, elements that have been written
15021500
// into the new RcBox will be dropped, then the memory freed.
@@ -2088,7 +2086,7 @@ impl<T, const N: usize> TryFrom<Rc<[T]>> for Rc<[T; N]> {
20882086

20892087
#[cfg(not(no_global_oom_handling))]
20902088
#[stable(feature = "shared_from_iter", since = "1.37.0")]
2091-
impl<T> iter::FromIterator<T> for Rc<[T]> {
2089+
impl<T> FromIterator<T> for Rc<[T]> {
20922090
/// Takes each element in the `Iterator` and collects it into an `Rc<[T]>`.
20932091
///
20942092
/// # Performance characteristics
@@ -2127,7 +2125,7 @@ impl<T> iter::FromIterator<T> for Rc<[T]> {
21272125
/// let evens: Rc<[u8]> = (0..10).collect(); // Just a single allocation happens here.
21282126
/// # assert_eq!(&*evens, &*(0..10).collect::<Vec<_>>());
21292127
/// ```
2130-
fn from_iter<I: iter::IntoIterator<Item = T>>(iter: I) -> Self {
2128+
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
21312129
ToRcSlice::to_rc_slice(iter.into_iter())
21322130
}
21332131
}
@@ -2204,9 +2202,9 @@ pub struct Weak<T: ?Sized> {
22042202
}
22052203

22062204
#[stable(feature = "rc_weak", since = "1.4.0")]
2207-
impl<T: ?Sized> !marker::Send for Weak<T> {}
2205+
impl<T: ?Sized> !Send for Weak<T> {}
22082206
#[stable(feature = "rc_weak", since = "1.4.0")]
2209-
impl<T: ?Sized> !marker::Sync for Weak<T> {}
2207+
impl<T: ?Sized> !Sync for Weak<T> {}
22102208

22112209
#[unstable(feature = "coerce_unsized", issue = "18598")]
22122210
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}

library/alloc/src/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
use core::error::Error;
4646
use core::fmt;
4747
use core::hash;
48-
use core::iter::FusedIterator;
4948
#[cfg(not(no_global_oom_handling))]
50-
use core::iter::{from_fn, FromIterator};
49+
use core::iter::from_fn;
50+
use core::iter::FusedIterator;
5151
#[cfg(not(no_global_oom_handling))]
5252
use core::ops::Add;
5353
#[cfg(not(no_global_oom_handling))]

library/alloc/src/sync.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
use core::any::Any;
1212
use core::borrow;
1313
use core::cmp::Ordering;
14-
use core::convert::{From, TryFrom};
1514
use core::fmt;
1615
use core::hash::{Hash, Hasher};
1716
use core::hint;
1817
use core::intrinsics::abort;
1918
#[cfg(not(no_global_oom_handling))]
2019
use core::iter;
21-
use core::marker::{PhantomData, Unpin, Unsize};
20+
use core::marker::{PhantomData, Unsize};
2221
#[cfg(not(no_global_oom_handling))]
2322
use core::mem::size_of_val;
2423
use core::mem::{self, align_of_val_raw};
@@ -188,8 +187,6 @@ macro_rules! acquire {
188187
/// [mutex]: ../../std/sync/struct.Mutex.html
189188
/// [rwlock]: ../../std/sync/struct.RwLock.html
190189
/// [atomic]: core::sync::atomic
191-
/// [`Send`]: core::marker::Send
192-
/// [`Sync`]: core::marker::Sync
193190
/// [deref]: core::ops::Deref
194191
/// [downgrade]: Arc::downgrade
195192
/// [upgrade]: Weak::upgrade
@@ -1241,7 +1238,7 @@ impl<T: ?Sized> Arc<T> {
12411238
#[inline]
12421239
#[stable(feature = "arc_mutate_strong_count", since = "1.51.0")]
12431240
pub unsafe fn decrement_strong_count(ptr: *const T) {
1244-
unsafe { mem::drop(Arc::from_raw(ptr)) };
1241+
unsafe { drop(Arc::from_raw(ptr)) };
12451242
}
12461243

12471244
#[inline]
@@ -1404,7 +1401,7 @@ impl<T> Arc<[T]> {
14041401
///
14051402
/// Behavior is undefined should the size be wrong.
14061403
#[cfg(not(no_global_oom_handling))]
1407-
unsafe fn from_iter_exact(iter: impl iter::Iterator<Item = T>, len: usize) -> Arc<[T]> {
1404+
unsafe fn from_iter_exact(iter: impl Iterator<Item = T>, len: usize) -> Arc<[T]> {
14081405
// Panic guard while cloning T elements.
14091406
// In the event of a panic, elements that have been written
14101407
// into the new ArcInner will be dropped, then the memory freed.
@@ -2818,7 +2815,7 @@ impl<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]> {
28182815

28192816
#[cfg(not(no_global_oom_handling))]
28202817
#[stable(feature = "shared_from_iter", since = "1.37.0")]
2821-
impl<T> iter::FromIterator<T> for Arc<[T]> {
2818+
impl<T> FromIterator<T> for Arc<[T]> {
28222819
/// Takes each element in the `Iterator` and collects it into an `Arc<[T]>`.
28232820
///
28242821
/// # Performance characteristics
@@ -2857,7 +2854,7 @@ impl<T> iter::FromIterator<T> for Arc<[T]> {
28572854
/// let evens: Arc<[u8]> = (0..10).collect(); // Just a single allocation happens here.
28582855
/// # assert_eq!(&*evens, &*(0..10).collect::<Vec<_>>());
28592856
/// ```
2860-
fn from_iter<I: iter::IntoIterator<Item = T>>(iter: I) -> Self {
2857+
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
28612858
ToArcSlice::to_arc_slice(iter.into_iter())
28622859
}
28632860
}

library/alloc/src/vec/cow.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::borrow::Cow;
2-
use core::iter::FromIterator;
32

43
use super::Vec;
54

library/alloc/src/vec/into_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<T, A: Allocator> IntoIter<T, A> {
108108
/// ```
109109
/// # let mut into_iter = Vec::<u8>::with_capacity(10).into_iter();
110110
/// let mut into_iter = std::mem::replace(&mut into_iter, Vec::new().into_iter());
111-
/// (&mut into_iter).for_each(core::mem::drop);
111+
/// (&mut into_iter).for_each(drop);
112112
/// std::mem::forget(into_iter);
113113
/// ```
114114
///

library/alloc/src/vec/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@
5656
#[cfg(not(no_global_oom_handling))]
5757
use core::cmp;
5858
use core::cmp::Ordering;
59-
use core::convert::TryFrom;
6059
use core::fmt;
6160
use core::hash::{Hash, Hasher};
6261
use core::iter;
63-
#[cfg(not(no_global_oom_handling))]
64-
use core::iter::FromIterator;
6562
use core::marker::PhantomData;
6663
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
6764
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
@@ -2990,7 +2987,7 @@ impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
29902987
}
29912988
}
29922989

2993-
/// Implements comparison of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
2990+
/// Implements comparison of vectors, [lexicographically](Ord#lexicographical-comparison).
29942991
#[stable(feature = "rust1", since = "1.0.0")]
29952992
impl<T: PartialOrd, A: Allocator> PartialOrd for Vec<T, A> {
29962993
#[inline]
@@ -3002,7 +2999,7 @@ impl<T: PartialOrd, A: Allocator> PartialOrd for Vec<T, A> {
30022999
#[stable(feature = "rust1", since = "1.0.0")]
30033000
impl<T: Eq, A: Allocator> Eq for Vec<T, A> {}
30043001

3005-
/// Implements ordering of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
3002+
/// Implements ordering of vectors, [lexicographically](Ord#lexicographical-comparison).
30063003
#[stable(feature = "rust1", since = "1.0.0")]
30073004
impl<T: Ord, A: Allocator> Ord for Vec<T, A> {
30083005
#[inline]

library/core/src/iter/sources/repeat_with.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use crate::ops::Try;
1919
/// please open a GitHub issue explaining your use case.
2020
///
2121
/// [`repeat()`]: crate::iter::repeat
22-
/// [`DoubleEndedIterator`]: crate::iter::DoubleEndedIterator
2322
///
2423
/// # Examples
2524
///

0 commit comments

Comments
 (0)