From d20b1190cfb92faab93e0528555753c3823d28d0 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Tue, 16 Apr 2024 20:59:17 +0200 Subject: [PATCH] Move BufGuard impl outside of function --- library/alloc/src/slice.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index 104f4ee753b..79540fcd395 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -864,18 +864,17 @@ fn stable_sort(v: &mut [T], mut is_less: F) where F: FnMut(&T, &T) -> bool, { - use sort::stable::BufGuard; - - #[unstable(issue = "none", feature = "std_internals")] - impl BufGuard for Vec { - fn with_capacity(capacity: usize) -> Self { - Vec::with_capacity(capacity) - } - - fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit] { - self.spare_capacity_mut() - } - } - sort::stable::sort::>(v, &mut is_less); } + +#[cfg(not(no_global_oom_handling))] +#[unstable(issue = "none", feature = "std_internals")] +impl sort::stable::BufGuard for Vec { + fn with_capacity(capacity: usize) -> Self { + Vec::with_capacity(capacity) + } + + fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit] { + self.spare_capacity_mut() + } +}