Skip to content

Commit a006328

Browse files
committed
Auto merge of #50611 - alexcrichton:rollup, r=alexcrichton
Rollup of 18 pull requests Successful merges: - #49423 (Extend tests for RFC1598 (GAT)) - #50010 (Give SliceIndex impls a test suite of girth befitting the implementation (and fix a UTF8 boundary check)) - #50447 (Fix update-references for tests within subdirectories.) - #50514 (Pull in a wasm fix from LLVM upstream) - #50524 (Make DepGraph::previous_work_products immutable) - #50532 (Don't use Lock for heavily accessed CrateMetadata::cnum_map.) - #50538 ( Make CrateNum allocation more thread-safe. ) - #50564 (Inline `Span` methods.) - #50565 (Use SmallVec for DepNodeIndex within dep_graph.) - #50569 (Allow for specifying a linker plugin for cross-language LTO) - #50572 (Clarify in the docs that `mul_add` is not always faster.) - #50574 (add fn `into_inner(self) -> (Idx, Idx)` to RangeInclusive (#49022)) - #50575 (std: Avoid `ptr::copy` if unnecessary in `vec::Drain`) - #50588 (Move "See also" disambiguation links for primitive types to top) - #50590 (Fix tuple struct field spans) - #50591 (Restore RawVec::reserve* documentation) - #50598 (Remove unnecessary mutable borrow and resizing in DepGraph::serialize) - #50606 (Retry when downloading the Docker cache.) Failed merges: - #50161 (added missing implementation hint) - #50558 (Remove all reference to DepGraph::work_products)
2 parents acd3871 + 2c5d13d commit a006328

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1384
-486
lines changed

src/ci/docker/run.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
3636
s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
3737
url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum"
3838
echo "Attempting to download $s3url"
39+
rm -f /tmp/rustci_docker_cache
3940
set +e
40-
loaded_images=$(curl $url | docker load | sed 's/.* sha/sha/')
41+
retry curl -f -L -C - -o /tmp/rustci_docker_cache "$url"
42+
loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/')
4143
set -e
4244
echo "Downloaded containers:\n$loaded_images"
4345
fi

src/ci/shared.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ function retry {
2121
while true; do
2222
"$@" && break || {
2323
if [[ $n -lt $max ]]; then
24+
sleep $n # don't retry immediately
2425
((n++))
2526
echo "Command failed. Attempt $n/$max:"
2627
else
2728
echo "The command has failed after $n attempts."
28-
exit 1
29+
return 1
2930
fi
3031
}
3132
done

src/liballoc/raw_vec.rs

+57-56
Original file line numberDiff line numberDiff line change
@@ -385,26 +385,7 @@ impl<T, A: Alloc> RawVec<T, A> {
385385
}
386386
}
387387

388-
/// Ensures that the buffer contains at least enough space to hold
389-
/// `used_cap + needed_extra_cap` elements. If it doesn't already,
390-
/// will reallocate the minimum possible amount of memory necessary.
391-
/// Generally this will be exactly the amount of memory necessary,
392-
/// but in principle the allocator is free to give back more than
393-
/// we asked for.
394-
///
395-
/// If `used_cap` exceeds `self.cap()`, this may fail to actually allocate
396-
/// the requested space. This is not really unsafe, but the unsafe
397-
/// code *you* write that relies on the behavior of this function may break.
398-
///
399-
/// # Panics
400-
///
401-
/// * Panics if the requested capacity exceeds `usize::MAX` bytes.
402-
/// * Panics on 32-bit platforms if the requested capacity exceeds
403-
/// `isize::MAX` bytes.
404-
///
405-
/// # Aborts
406-
///
407-
/// Aborts on OOM
388+
/// The same as `reserve_exact`, but returns on errors instead of panicking or aborting.
408389
pub fn try_reserve_exact(&mut self, used_cap: usize, needed_extra_cap: usize)
409390
-> Result<(), CollectionAllocErr> {
410391

@@ -441,6 +422,26 @@ impl<T, A: Alloc> RawVec<T, A> {
441422
}
442423
}
443424

425+
/// Ensures that the buffer contains at least enough space to hold
426+
/// `used_cap + needed_extra_cap` elements. If it doesn't already,
427+
/// will reallocate the minimum possible amount of memory necessary.
428+
/// Generally this will be exactly the amount of memory necessary,
429+
/// but in principle the allocator is free to give back more than
430+
/// we asked for.
431+
///
432+
/// If `used_cap` exceeds `self.cap()`, this may fail to actually allocate
433+
/// the requested space. This is not really unsafe, but the unsafe
434+
/// code *you* write that relies on the behavior of this function may break.
435+
///
436+
/// # Panics
437+
///
438+
/// * Panics if the requested capacity exceeds `usize::MAX` bytes.
439+
/// * Panics on 32-bit platforms if the requested capacity exceeds
440+
/// `isize::MAX` bytes.
441+
///
442+
/// # Aborts
443+
///
444+
/// Aborts on OOM
444445
pub fn reserve_exact(&mut self, used_cap: usize, needed_extra_cap: usize) {
445446
match self.try_reserve_exact(used_cap, needed_extra_cap) {
446447
Err(CapacityOverflow) => capacity_overflow(),
@@ -463,6 +464,42 @@ impl<T, A: Alloc> RawVec<T, A> {
463464
Ok(cmp::max(double_cap, required_cap))
464465
}
465466

467+
/// The same as `reserve`, but returns on errors instead of panicking or aborting.
468+
pub fn try_reserve(&mut self, used_cap: usize, needed_extra_cap: usize)
469+
-> Result<(), CollectionAllocErr> {
470+
unsafe {
471+
// NOTE: we don't early branch on ZSTs here because we want this
472+
// to actually catch "asking for more than usize::MAX" in that case.
473+
// If we make it past the first branch then we are guaranteed to
474+
// panic.
475+
476+
// Don't actually need any more capacity.
477+
// Wrapping in case they give a bad `used_cap`
478+
if self.cap().wrapping_sub(used_cap) >= needed_extra_cap {
479+
return Ok(());
480+
}
481+
482+
let new_cap = self.amortized_new_size(used_cap, needed_extra_cap)?;
483+
let new_layout = Layout::array::<T>(new_cap).map_err(|_| CapacityOverflow)?;
484+
485+
// FIXME: may crash and burn on over-reserve
486+
alloc_guard(new_layout.size())?;
487+
488+
let res = match self.current_layout() {
489+
Some(layout) => {
490+
debug_assert!(new_layout.align() == layout.align());
491+
self.a.realloc(NonNull::from(self.ptr).as_opaque(), layout, new_layout.size())
492+
}
493+
None => self.a.alloc(new_layout),
494+
};
495+
496+
self.ptr = res?.cast().into();
497+
self.cap = new_cap;
498+
499+
Ok(())
500+
}
501+
}
502+
466503
/// Ensures that the buffer contains at least enough space to hold
467504
/// `used_cap + needed_extra_cap` elements. If it doesn't already have
468505
/// enough capacity, will reallocate enough space plus comfortable slack
@@ -515,42 +552,6 @@ impl<T, A: Alloc> RawVec<T, A> {
515552
/// # vector.push_all(&[1, 3, 5, 7, 9]);
516553
/// # }
517554
/// ```
518-
pub fn try_reserve(&mut self, used_cap: usize, needed_extra_cap: usize)
519-
-> Result<(), CollectionAllocErr> {
520-
unsafe {
521-
// NOTE: we don't early branch on ZSTs here because we want this
522-
// to actually catch "asking for more than usize::MAX" in that case.
523-
// If we make it past the first branch then we are guaranteed to
524-
// panic.
525-
526-
// Don't actually need any more capacity.
527-
// Wrapping in case they give a bad `used_cap`
528-
if self.cap().wrapping_sub(used_cap) >= needed_extra_cap {
529-
return Ok(());
530-
}
531-
532-
let new_cap = self.amortized_new_size(used_cap, needed_extra_cap)?;
533-
let new_layout = Layout::array::<T>(new_cap).map_err(|_| CapacityOverflow)?;
534-
535-
// FIXME: may crash and burn on over-reserve
536-
alloc_guard(new_layout.size())?;
537-
538-
let res = match self.current_layout() {
539-
Some(layout) => {
540-
debug_assert!(new_layout.align() == layout.align());
541-
self.a.realloc(NonNull::from(self.ptr).as_opaque(), layout, new_layout.size())
542-
}
543-
None => self.a.alloc(new_layout),
544-
};
545-
546-
self.ptr = res?.cast().into();
547-
self.cap = new_cap;
548-
549-
Ok(())
550-
}
551-
}
552-
553-
/// The same as try_reserve, but errors are lowered to a call to oom().
554555
pub fn reserve(&mut self, used_cap: usize, needed_extra_cap: usize) {
555556
match self.try_reserve(used_cap, needed_extra_cap) {
556557
Err(CapacityOverflow) => capacity_overflow(),

src/liballoc/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! A dynamically-sized view into a contiguous sequence, `[T]`.
1212
//!
13+
//! *[See also the slice primitive type](../../std/primitive.slice.html).*
14+
//!
1315
//! Slices are a view into a block of memory represented as a pointer and a
1416
//! length.
1517
//!
@@ -78,8 +80,6 @@
7880
//! * Further methods that return iterators are [`.split`], [`.splitn`],
7981
//! [`.chunks`], [`.windows`] and more.
8082
//!
81-
//! *[See also the slice primitive type](../../std/primitive.slice.html).*
82-
//!
8383
//! [`Clone`]: ../../std/clone/trait.Clone.html
8484
//! [`Eq`]: ../../std/cmp/trait.Eq.html
8585
//! [`Ord`]: ../../std/cmp/trait.Ord.html

src/liballoc/str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Unicode string slices.
1212
//!
13+
//! *[See also the `str` primitive type](../../std/primitive.str.html).*
14+
//!
1315
//! The `&str` type is one of the two main string types, the other being `String`.
1416
//! Unlike its `String` counterpart, its contents are borrowed.
1517
//!
@@ -29,8 +31,6 @@
2931
//! ```
3032
//! let hello_world: &'static str = "Hello, world!";
3133
//! ```
32-
//!
33-
//! *[See also the `str` primitive type](../../std/primitive.str.html).*
3434
3535
#![stable(feature = "rust1", since = "1.0.0")]
3636

0 commit comments

Comments
 (0)