diff options
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/alloc.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 62 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 13 | ||||
| -rw-r--r-- | library/alloc/src/rc.rs | 10 | ||||
| -rw-r--r-- | library/alloc/src/string.rs | 25 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 10 | ||||
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 4 | ||||
| -rw-r--r-- | library/alloc/src/vec/spec_extend.rs | 4 |
8 files changed, 43 insertions, 86 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index c8751ba4911..5205ed9fb50 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -392,7 +392,6 @@ pub mod __alloc_error_handler { static __rust_alloc_error_handler_should_panic: u8; } - #[allow(unused_unsafe)] if unsafe { __rust_alloc_error_handler_should_panic != 0 } { panic!("memory allocation of {size} bytes failed") } else { diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index ff908ec12ec..5481b327d69 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -613,8 +613,6 @@ impl<K, V> BTreeMap<K, V> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -636,8 +634,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -661,8 +657,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// # #![feature(allocator_api)] /// # #![feature(btreemap_alloc)] @@ -688,8 +682,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -744,8 +736,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -830,8 +820,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -917,8 +905,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -943,8 +929,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -982,8 +966,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1017,8 +999,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(map_try_insert)] /// @@ -1051,8 +1031,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1078,8 +1056,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1208,8 +1184,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// use std::ops::Bound::Included; @@ -1251,8 +1225,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1283,8 +1255,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1336,8 +1306,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2388,8 +2356,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2420,8 +2386,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2453,8 +2417,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2474,8 +2436,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2495,8 +2455,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2521,8 +2479,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2546,8 +2502,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2578,8 +2532,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2591,6 +2543,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// a.insert(2, "b"); /// a.insert(3, "c"); /// a.insert(4, "c"); + /// let cursor = a.lower_bound(Bound::Included(&2)); + /// assert_eq!(cursor.key(), Some(&2)); /// let cursor = a.lower_bound(Bound::Excluded(&2)); /// assert_eq!(cursor.key(), Some(&3)); /// ``` @@ -2619,8 +2573,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2632,6 +2584,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// a.insert(2, "b"); /// a.insert(3, "c"); /// a.insert(4, "c"); + /// let cursor = a.lower_bound_mut(Bound::Included(&2)); + /// assert_eq!(cursor.key(), Some(&2)); /// let cursor = a.lower_bound_mut(Bound::Excluded(&2)); /// assert_eq!(cursor.key(), Some(&3)); /// ``` @@ -2673,8 +2627,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2686,6 +2638,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// a.insert(2, "b"); /// a.insert(3, "c"); /// a.insert(4, "c"); + /// let cursor = a.upper_bound(Bound::Included(&3)); + /// assert_eq!(cursor.key(), Some(&3)); /// let cursor = a.upper_bound(Bound::Excluded(&3)); /// assert_eq!(cursor.key(), Some(&2)); /// ``` @@ -2714,8 +2668,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2727,6 +2679,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// a.insert(2, "b"); /// a.insert(3, "c"); /// a.insert(4, "c"); + /// let cursor = a.upper_bound_mut(Bound::Included(&3)); + /// assert_eq!(cursor.key(), Some(&3)); /// let cursor = a.upper_bound_mut(Bound::Excluded(&3)); /// assert_eq!(cursor.key(), Some(&2)); /// ``` diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index c4461040b20..9da230915b8 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1121,19 +1121,6 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> { /// ``` /// use std::collections::BTreeSet; /// - /// let set = BTreeSet::from([1, 2, 3]); - /// let mut set_iter = set.iter(); - /// assert_eq!(set_iter.next(), Some(&1)); - /// assert_eq!(set_iter.next(), Some(&2)); - /// assert_eq!(set_iter.next(), Some(&3)); - /// assert_eq!(set_iter.next(), None); - /// ``` - /// - /// Values returned by the iterator are returned in ascending order: - /// - /// ``` - /// use std::collections::BTreeSet; - /// /// let set = BTreeSet::from([3, 1, 2]); /// let mut set_iter = set.iter(); /// assert_eq!(set_iter.next(), Some(&1)); diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index b3ec830a7d7..60b07485c3a 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -661,10 +661,14 @@ impl<T> Rc<T> { impl<T, A: Allocator> Rc<T, A> { /// Returns a reference to the underlying allocator. + /// + /// Note: this is an associated function, which means that you have + /// to call it as `Rc::allocator(&r)` instead of `r.allocator()`. This + /// is so that there is no conflict with a method on the inner type. #[inline] #[unstable(feature = "allocator_api", issue = "32838")] - pub fn allocator(&self) -> &A { - &self.alloc + pub fn allocator(this: &Self) -> &A { + &this.alloc } /// Constructs a new `Rc` in the provided allocator. /// @@ -2715,7 +2719,7 @@ impl<T> Weak<T> { /// ``` #[inline] #[stable(feature = "downgraded_weak", since = "1.10.0")] - #[rustc_const_unstable(feature = "const_weak_new", issue = "95091", reason = "recently added")] + #[rustc_const_stable(feature = "const_weak_new", since = "CURRENT_RUSTC_VERSION")] #[must_use] pub const fn new() -> Weak<T> { Weak { diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index ad7b77f5497..9254786d129 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -1290,11 +1290,11 @@ impl String { /// Basic usage: /// /// ``` - /// let mut s = String::from("foo"); + /// let mut s = String::from("abč"); /// - /// assert_eq!(s.pop(), Some('o')); - /// assert_eq!(s.pop(), Some('o')); - /// assert_eq!(s.pop(), Some('f')); + /// assert_eq!(s.pop(), Some('č')); + /// assert_eq!(s.pop(), Some('b')); + /// assert_eq!(s.pop(), Some('a')); /// /// assert_eq!(s.pop(), None); /// ``` @@ -1324,11 +1324,11 @@ impl String { /// Basic usage: /// /// ``` - /// let mut s = String::from("foo"); + /// let mut s = String::from("abç"); /// - /// assert_eq!(s.remove(0), 'f'); - /// assert_eq!(s.remove(1), 'o'); - /// assert_eq!(s.remove(0), 'o'); + /// assert_eq!(s.remove(0), 'a'); + /// assert_eq!(s.remove(1), 'ç'); + /// assert_eq!(s.remove(0), 'b'); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -2527,6 +2527,7 @@ impl<T: fmt::Display + ?Sized> ToString for T { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[unstable(feature = "ascii_char", issue = "110998")] impl ToString for core::ascii::Char { @@ -2536,6 +2537,7 @@ impl ToString for core::ascii::Char { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "char_to_string_specialization", since = "1.46.0")] impl ToString for char { @@ -2545,6 +2547,7 @@ impl ToString for char { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "bool_to_string_specialization", since = "1.68.0")] impl ToString for bool { @@ -2554,6 +2557,7 @@ impl ToString for bool { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "u8_to_string_specialization", since = "1.54.0")] impl ToString for u8 { @@ -2574,6 +2578,7 @@ impl ToString for u8 { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "i8_to_string_specialization", since = "1.54.0")] impl ToString for i8 { @@ -2597,6 +2602,7 @@ impl ToString for i8 { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "str_to_string_specialization", since = "1.9.0")] impl ToString for str { @@ -2606,6 +2612,7 @@ impl ToString for str { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "cow_str_to_string_specialization", since = "1.17.0")] impl ToString for Cow<'_, str> { @@ -2615,6 +2622,7 @@ impl ToString for Cow<'_, str> { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "string_to_string_specialization", since = "1.17.0")] impl ToString for String { @@ -2624,6 +2632,7 @@ impl ToString for String { } } +#[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "fmt_arguments_to_string_specialization", since = "1.71.0")] impl ToString for fmt::Arguments<'_> { diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index e00850eb5d8..6c701225a84 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -678,10 +678,14 @@ impl<T> Arc<T> { impl<T, A: Allocator> Arc<T, A> { /// Returns a reference to the underlying allocator. + /// + /// Note: this is an associated function, which means that you have + /// to call it as `Arc::allocator(&a)` instead of `a.allocator()`. This + /// is so that there is no conflict with a method on the inner type. #[inline] #[unstable(feature = "allocator_api", issue = "32838")] - pub fn allocator(&self) -> &A { - &self.alloc + pub fn allocator(this: &Self) -> &A { + &this.alloc } /// Constructs a new `Arc<T>` in the provided allocator. /// @@ -2499,7 +2503,7 @@ impl<T> Weak<T> { /// ``` #[inline] #[stable(feature = "downgraded_weak", since = "1.10.0")] - #[rustc_const_unstable(feature = "const_weak_new", issue = "95091", reason = "recently added")] + #[rustc_const_stable(feature = "const_weak_new", since = "CURRENT_RUSTC_VERSION")] #[must_use] pub const fn new() -> Weak<T> { Weak { diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 598ecf05e82..e45ddc7896b 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -213,7 +213,7 @@ mod spec_extend; /// /// # Indexing /// -/// The `Vec` type allows to access values by index, because it implements the +/// The `Vec` type allows access to values by index, because it implements the /// [`Index`] trait. An example will be more explicit: /// /// ``` @@ -2961,7 +2961,7 @@ impl<T, A: Allocator> Vec<T, A> { /// [`copy_from_slice`]: slice::copy_from_slice #[cfg(not(no_global_oom_handling))] #[stable(feature = "extend_ref", since = "1.2.0")] -impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> { +impl<'a, T: Copy + 'a, A: Allocator> Extend<&'a T> for Vec<T, A> { fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) { self.spec_extend(iter.into_iter()) } diff --git a/library/alloc/src/vec/spec_extend.rs b/library/alloc/src/vec/spec_extend.rs index 56065ce565b..e2f865d0f71 100644 --- a/library/alloc/src/vec/spec_extend.rs +++ b/library/alloc/src/vec/spec_extend.rs @@ -36,7 +36,7 @@ impl<T, A: Allocator> SpecExtend<T, IntoIter<T>> for Vec<T, A> { } } -impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A> +impl<'a, T: 'a, I, A: Allocator> SpecExtend<&'a T, I> for Vec<T, A> where I: Iterator<Item = &'a T>, T: Clone, @@ -46,7 +46,7 @@ where } } -impl<'a, T: 'a, A: Allocator + 'a> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A> +impl<'a, T: 'a, A: Allocator> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A> where T: Copy, { |
