Skip to content

Commit e0e95a7

Browse files
committed
Auto merge of #154815 - JonathanBrouwer:rollup-sdqRx2J, r=JonathanBrouwer
Rollup of 8 pull requests Successful merges: - #149868 (rustc: Stop passing `--allow-undefined` on wasm targets) - #153555 (Clarified docs in std::sync::RwLock + added test to ensure that max reader count is respected) - #152851 (Fix SGX delayed host lookup via ToSocketAddr) - #154051 (use libm for acosh and asinh) - #154581 (More informative `Debug for vec::ExtractIf`) - #154461 (Edit the docs new_in() and with_capacity_in()) - #154526 (Panic/return false on overflow in no_threads read/try_read impl) - #154798 (rustdoc-search: match path components on words)
2 parents 0312a55 + 4210825 commit e0e95a7

File tree

34 files changed

+441
-135
lines changed

34 files changed

+441
-135
lines changed

compiler/rustc_target/src/spec/base/wasm.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ pub(crate) fn options() -> TargetOptions {
2828
// stack overflow will be guaranteed to trap as it underflows instead of
2929
// corrupting static data.
3030
concat!($prefix, "--stack-first"),
31-
// FIXME we probably shouldn't pass this but instead pass an explicit list
32-
// of symbols we'll allow to be undefined. We don't currently have a
33-
// mechanism of knowing, however, which symbols are intended to be imported
34-
// from the environment and which are intended to be imported from other
35-
// objects linked elsewhere. This is a coarse approximation but is sure to
36-
// hide some bugs and frustrate someone at some point, so we should ideally
37-
// work towards a world where we can explicitly list symbols that are
38-
// supposed to be imported and have all other symbols generate errors if
39-
// they remain undefined.
40-
concat!($prefix, "--allow-undefined"),
4131
// LLD only implements C++-like demangling, which doesn't match our own
4232
// mangling scheme. Tell LLD to not demangle anything and leave it up to
4333
// us to demangle these symbols later. Currently rustc does not perform

library/alloc/src/boxed.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,15 @@ impl<T, A: Allocator> Box<T, A> {
695695
/// does the same as <code>[Box::into_pin]\([Box::new_in]\(x, alloc))</code>. Consider using
696696
/// [`into_pin`](Box::into_pin) if you already have a `Box<T, A>`, or if you want to
697697
/// construct a (pinned) `Box` in a different way than with [`Box::new_in`].
698+
///
699+
/// # Examples
700+
///
701+
/// ```
702+
/// #![feature(allocator_api)]
703+
/// use std::alloc::System;
704+
///
705+
/// let x = Box::pin_in(1, System);
706+
/// ```
698707
#[cfg(not(no_global_oom_handling))]
699708
#[unstable(feature = "allocator_api", issue = "32838")]
700709
#[must_use]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ impl<T, A: Allocator> BinaryHeap<T, A> {
549549
///
550550
/// use std::alloc::System;
551551
/// use std::collections::BinaryHeap;
552-
/// let mut heap = BinaryHeap::new_in(System);
553-
/// heap.push(4);
552+
///
553+
/// let heap : BinaryHeap<i32, System> = BinaryHeap::new_in(System);
554554
/// ```
555555
#[unstable(feature = "allocator_api", issue = "32838")]
556556
#[must_use]
@@ -573,8 +573,8 @@ impl<T, A: Allocator> BinaryHeap<T, A> {
573573
///
574574
/// use std::alloc::System;
575575
/// use std::collections::BinaryHeap;
576-
/// let mut heap = BinaryHeap::with_capacity_in(10, System);
577-
/// heap.push(4);
576+
///
577+
/// let heap: BinaryHeap<i32, System> = BinaryHeap::with_capacity_in(10, System);
578578
/// ```
579579
#[unstable(feature = "allocator_api", issue = "32838")]
580580
#[must_use]

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,13 +684,11 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
684684
/// ```
685685
/// # #![feature(allocator_api)]
686686
/// # #![feature(btreemap_alloc)]
687+
///
687688
/// use std::collections::BTreeMap;
688689
/// use std::alloc::Global;
689690
///
690-
/// let mut map = BTreeMap::new_in(Global);
691-
///
692-
/// // entries can now be inserted into the empty map
693-
/// map.insert(1, "a");
691+
/// let map: BTreeMap<i32, i32> = BTreeMap::new_in(Global);
694692
/// ```
695693
#[unstable(feature = "btreemap_alloc", issue = "32838")]
696694
#[must_use]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
355355
/// # #![allow(unused_mut)]
356356
/// # #![feature(allocator_api)]
357357
/// # #![feature(btreemap_alloc)]
358+
///
358359
/// use std::collections::BTreeSet;
359360
/// use std::alloc::Global;
360361
///
361-
/// let mut set: BTreeSet<i32> = BTreeSet::new_in(Global);
362+
/// let set: BTreeSet<i32> = BTreeSet::new_in(Global);
362363
/// ```
363364
#[unstable(feature = "btreemap_alloc", issue = "32838")]
364365
#[must_use]

library/alloc/src/collections/linked_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
509509
/// use std::alloc::System;
510510
/// use std::collections::LinkedList;
511511
///
512-
/// let list: LinkedList<u32, _> = LinkedList::new_in(System);
512+
/// let list: LinkedList<i32, System> = LinkedList::new_in(System);
513513
/// ```
514514
#[inline]
515515
#[unstable(feature = "allocator_api", issue = "32838")]

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ impl<T> VecDeque<T> {
790790
/// ```
791791
/// use std::collections::VecDeque;
792792
///
793-
/// let deque: VecDeque<u32> = VecDeque::with_capacity(10);
793+
/// let deque: VecDeque<i32> = VecDeque::with_capacity(10);
794794
/// ```
795795
#[inline]
796796
#[stable(feature = "rust1", since = "1.0.0")]
@@ -830,9 +830,12 @@ impl<T, A: Allocator> VecDeque<T, A> {
830830
/// # Examples
831831
///
832832
/// ```
833+
/// # #![feature(allocator_api)]
834+
///
833835
/// use std::collections::VecDeque;
836+
/// use std::alloc::Global;
834837
///
835-
/// let deque: VecDeque<u32> = VecDeque::new();
838+
/// let deque: VecDeque<i32> = VecDeque::new_in(Global);
836839
/// ```
837840
#[inline]
838841
#[unstable(feature = "allocator_api", issue = "32838")]
@@ -845,9 +848,12 @@ impl<T, A: Allocator> VecDeque<T, A> {
845848
/// # Examples
846849
///
847850
/// ```
851+
/// # #![feature(allocator_api)]
852+
///
848853
/// use std::collections::VecDeque;
854+
/// use std::alloc::Global;
849855
///
850-
/// let deque: VecDeque<u32> = VecDeque::with_capacity(10);
856+
/// let deque: VecDeque<i32> = VecDeque::with_capacity_in(10, Global);
851857
/// ```
852858
#[unstable(feature = "allocator_api", issue = "32838")]
853859
pub fn with_capacity_in(capacity: usize, alloc: A) -> VecDeque<T, A> {

library/alloc/src/rc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ impl<T, A: Allocator> Rc<T, A> {
737737
///
738738
/// ```
739739
/// #![feature(allocator_api)]
740+
///
740741
/// use std::rc::Rc;
741742
/// use std::alloc::System;
742743
///

library/alloc/src/vec/extract_if.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,25 @@ where
130130
A: Allocator,
131131
{
132132
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
133-
let peek = if self.idx < self.end {
134-
// This has to use pointer arithmetic as `self.vec[self.idx]` or
135-
// `self.vec.get_unchecked(self.idx)` wouldn't work since we
136-
// temporarily set the length of `self.vec` to zero.
137-
//
138-
// SAFETY:
139-
// Since `self.idx` is smaller than `self.end` and `self.end` is
140-
// smaller than `self.old_len`, `idx` is valid for indexing the
141-
// buffer. Also, per the invariant of `self.idx`, this element
142-
// has not been inspected/moved out yet.
143-
Some(unsafe { &*self.vec.as_ptr().add(self.idx) })
144-
} else {
145-
None
146-
};
147-
f.debug_struct("ExtractIf").field("peek", &peek).finish_non_exhaustive()
133+
// We have to use pointer arithmetics here,
134+
// because the length of `self.vec` is temporarily set to 0.
135+
let start = self.vec.as_ptr();
136+
137+
// SAFETY: we always keep first `self.idx - self.del` elements valid.
138+
let retained = unsafe { slice::from_raw_parts(start, self.idx - self.del) };
139+
140+
// SAFETY: we have not yet touched elements starting at `self.idx`.
141+
let valid_tail =
142+
unsafe { slice::from_raw_parts(start.add(self.idx), self.old_len - self.idx) };
143+
144+
// SAFETY: `end - idx <= old_len - idx`, because `end <= old_len`. Also `idx <= end` by invariant.
145+
let (remainder, skipped_tail) =
146+
unsafe { valid_tail.split_at_unchecked(self.end - self.idx) };
147+
148+
f.debug_struct("ExtractIf")
149+
.field("retained", &retained)
150+
.field("remainder", &remainder)
151+
.field("skipped_tail", &skipped_tail)
152+
.finish_non_exhaustive()
148153
}
149154
}

library/alloc/src/vec/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,7 @@ impl<T, A: Allocator> Vec<T, A> {
10621062
///
10631063
/// use std::alloc::System;
10641064
///
1065-
/// # #[allow(unused_mut)]
1066-
/// let mut vec: Vec<i32, _> = Vec::new_in(System);
1065+
/// let vec: Vec<i32, System> = Vec::new_in(System);
10671066
/// ```
10681067
#[inline]
10691068
#[unstable(feature = "allocator_api", issue = "32838")]

0 commit comments

Comments
 (0)