Skip to content

Commit 7464c5b

Browse files
authored
Rollup merge of rust-lang#98652 - ojeda:warning-free-no_global_oom_handling, r=joshtriplett
`alloc`: clean and ensure `no_global_oom_handling` builds are warning-free Rust 1.62.0 introduced a couple new `unused_imports` warnings in `no_global_oom_handling` builds, making a total of 5 warnings. <details> ```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) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ ``` </details> This PR cleans them and ensures no new ones are introduced so that projects compiling `alloc` without infallible allocations do not see them (and may want to enable `-Dwarnings`). The couple `dead_code` ones may be reverted when some fallible allocation support starts using them.
2 parents 87cbd8c + 2a52036 commit 7464c5b

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

alloc/src/boxed/thin.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// by matthieu-m
44
use crate::alloc::{self, Layout, LayoutError};
55
use core::fmt::{self, Debug, Display, Formatter};
6-
use core::marker::{PhantomData, Unsize};
6+
use core::marker::PhantomData;
7+
#[cfg(not(no_global_oom_handling))]
8+
use core::marker::Unsize;
79
use core::mem;
810
use core::ops::{Deref, DerefMut};
911
use core::ptr::Pointee;

alloc/src/raw_vec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ impl<T, A: Allocator> RawVec<T, A> {
421421
Ok(())
422422
}
423423

424+
#[cfg(not(no_global_oom_handling))]
424425
fn shrink(&mut self, cap: usize) -> Result<(), TryReserveError> {
425426
assert!(cap <= self.capacity(), "Tried to shrink to a larger capacity");
426427

alloc/src/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
use core::char::{decode_utf16, REPLACEMENT_CHARACTER};
4747
use core::fmt;
4848
use core::hash;
49+
use core::iter::FusedIterator;
4950
#[cfg(not(no_global_oom_handling))]
50-
use core::iter::FromIterator;
51-
use core::iter::{from_fn, FusedIterator};
51+
use core::iter::{from_fn, FromIterator};
5252
#[cfg(not(no_global_oom_handling))]
5353
use core::ops::Add;
5454
#[cfg(not(no_global_oom_handling))]

alloc/src/vec/into_iter.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use core::iter::{
99
};
1010
use core::marker::PhantomData;
1111
use core::mem::{self, ManuallyDrop};
12+
#[cfg(not(no_global_oom_handling))]
1213
use core::ops::Deref;
1314
use core::ptr::{self, NonNull};
1415
use core::slice::{self};
@@ -123,6 +124,7 @@ impl<T, A: Allocator> IntoIter<T, A> {
123124
}
124125

125126
/// Forgets to Drop the remaining elements while still allowing the backing allocation to be freed.
127+
#[cfg(not(no_global_oom_handling))]
126128
pub(crate) fn forget_remaining_elements(&mut self) {
127129
self.ptr = self.end;
128130
}

0 commit comments

Comments
 (0)