diff options
| author | Miguel Ojeda <ojeda@kernel.org> | 2022-06-29 01:09:02 +0200 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2022-06-29 04:44:23 +0200 |
| commit | 83addf2540ce7ce7d0f875fdbe2a7cd0e7f52d97 (patch) | |
| tree | a3c0cf3caf5b40d733f17e9228cf96d0b3d82bf8 /library/alloc/src | |
| parent | 2953edc7b7a00d14c4ba940ebb46b4e7148a9d71 (diff) | |
| download | rust-83addf2540ce7ce7d0f875fdbe2a7cd0e7f52d97.tar.gz rust-83addf2540ce7ce7d0f875fdbe2a7cd0e7f52d97.zip | |
alloc: fix `no_global_oom_handling` warnings
Rust 1.62.0 introduced a couple new `unused_imports` warnings
in `no_global_oom_handling` builds, making a total of 5 warnings:
```txt
warning: unused import: `Unsize`
--> library/alloc/src/boxed/thin.rs:6:33
|
6 | use core::marker::{PhantomData, Unsize};
| ^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `from_fn`
--> library/alloc/src/string.rs:51:18
|
51 | use core::iter::{from_fn, FusedIterator};
| ^^^^^^^
warning: unused import: `core::ops::Deref`
--> library/alloc/src/vec/into_iter.rs:12:5
|
12 | use core::ops::Deref;
| ^^^^^^^^^^^^^^^^
warning: associated function `shrink` is never used
--> library/alloc/src/raw_vec.rs:424:8
|
424 | fn shrink(&mut self, cap: usize) -> Result<(), TryReserveError> {
| ^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: associated function `forget_remaining_elements` is never used
--> library/alloc/src/vec/into_iter.rs:126:19
|
126 | pub(crate) fn forget_remaining_elements(&mut self) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
```
This patch cleans them so that projects compiling `alloc` without
infallible allocations do not see the warnings. It also enables
the use of `-Dwarnings`.
The couple `dead_code` ones may be reverted when some fallible
allocation support starts using them.
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/boxed/thin.rs | 4 | ||||
| -rw-r--r-- | library/alloc/src/raw_vec.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/string.rs | 4 | ||||
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 203e5dff0c7..09308d4d090 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -3,7 +3,9 @@ // by matthieu-m use crate::alloc::{self, Layout, LayoutError}; use core::fmt::{self, Debug, Display, Formatter}; -use core::marker::{PhantomData, Unsize}; +use core::marker::PhantomData; +#[cfg(not(no_global_oom_handling))] +use core::marker::Unsize; use core::mem; use core::ops::{Deref, DerefMut}; use core::ptr::Pointee; diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 4be5f6cf9ca..b0f4529abdf 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -421,6 +421,7 @@ impl<T, A: Allocator> RawVec<T, A> { Ok(()) } + #[cfg(not(no_global_oom_handling))] fn shrink(&mut self, cap: usize) -> Result<(), TryReserveError> { assert!(cap <= self.capacity(), "Tried to shrink to a larger capacity"); diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 88838807265..b1513e5e0f3 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -46,9 +46,9 @@ use core::char::{decode_utf16, REPLACEMENT_CHARACTER}; use core::fmt; use core::hash; +use core::iter::FusedIterator; #[cfg(not(no_global_oom_handling))] -use core::iter::FromIterator; -use core::iter::{from_fn, FusedIterator}; +use core::iter::{from_fn, FromIterator}; #[cfg(not(no_global_oom_handling))] use core::ops::Add; #[cfg(not(no_global_oom_handling))] diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 9b84a1d9b4b..28979457b7f 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -9,6 +9,7 @@ use core::iter::{ }; use core::marker::PhantomData; use core::mem::{self, ManuallyDrop}; +#[cfg(not(no_global_oom_handling))] use core::ops::Deref; use core::ptr::{self, NonNull}; use core::slice::{self}; @@ -123,6 +124,7 @@ impl<T, A: Allocator> IntoIter<T, A> { } /// Forgets to Drop the remaining elements while still allowing the backing allocation to be freed. + #[cfg(not(no_global_oom_handling))] pub(crate) fn forget_remaining_elements(&mut self) { self.ptr = self.end; } |
