Skip to content

Commit 36b5951

Browse files
committed
Auto merge of #67648 - Mark-Simulacrum:rollup-dttcu1y, r=Mark-Simulacrum
Rollup of 12 pull requests Successful merges: - #67112 (Refactor expression parsing thoroughly) - #67192 (Various const eval and pattern matching ICE fixes) - #67287 (typeck: note other end-point when checking range pats) - #67459 (prune ill-conceived BTreeMap iter_mut assertion and test its mutability) - #67576 (reuse `capacity` variable in slice::repeat) - #67602 (Use issue = "none" instead of "0" in intrinsics) - #67614 (Set callbacks globally) - #67617 (Remove `compiler_builtins_lib` documentation) - #67629 (Remove redundant link texts) - #67632 (Convert collapsed to shortcut reference links) - #67633 (Update .mailmap) - #67635 (Document safety of Path casting) Failed merges: r? @ghost
2 parents 3e0a1c0 + bcb7553 commit 36b5951

File tree

93 files changed

+1178
-834
lines changed

Some content is hidden

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

93 files changed

+1178
-834
lines changed

.mailmap

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ Chris C Cerami <[email protected]> Chris C Cerami <chrisccer
5454
Chris Pressey <[email protected]>
5555
Chris Thorn <[email protected]> Chris Thorn <[email protected]>
5656
Chris Vittal <[email protected]> Christopher Vittal <[email protected]>
57-
58-
59-
57+
58+
59+
60+
6061
6162
Clinton Ryan <[email protected]>
6263
Corey Richardson <[email protected]> Elaine "See More" Nemo <[email protected]>

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ labels to triage issues:
367367
to fix the issue.
368368

369369
* The dark blue **final-comment-period** label marks bugs that are using the
370-
RFC signoff functionality of [rfcbot][rfcbot] and are currently in the final
370+
RFC signoff functionality of [rfcbot] and are currently in the final
371371
comment period.
372372

373373
* Red, **I**-prefixed labels indicate the **importance** of the issue. The
@@ -385,7 +385,7 @@ labels to triage issues:
385385
label.
386386

387387
* The gray **proposed-final-comment-period** label marks bugs that are using
388-
the RFC signoff functionality of [rfcbot][rfcbot] and are currently awaiting
388+
the RFC signoff functionality of [rfcbot] and are currently awaiting
389389
signoff of all team members in order to enter the final comment period.
390390

391391
* Pink, **regression**-prefixed labels track regressions from stable to the

RELEASES.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -4951,10 +4951,10 @@ Stabilized APIs
49514951
---------------
49524952

49534953
* [`std::panic`]
4954-
* [`std::panic::catch_unwind`][] (renamed from `recover`)
4955-
* [`std::panic::resume_unwind`][] (renamed from `propagate`)
4956-
* [`std::panic::AssertUnwindSafe`][] (renamed from `AssertRecoverSafe`)
4957-
* [`std::panic::UnwindSafe`][] (renamed from `RecoverSafe`)
4954+
* [`std::panic::catch_unwind`] (renamed from `recover`)
4955+
* [`std::panic::resume_unwind`] (renamed from `propagate`)
4956+
* [`std::panic::AssertUnwindSafe`] (renamed from `AssertRecoverSafe`)
4957+
* [`std::panic::UnwindSafe`] (renamed from `RecoverSafe`)
49584958
* [`str::is_char_boundary`]
49594959
* [`<*const T>::as_ref`]
49604960
* [`<*mut T>::as_ref`]
@@ -5234,18 +5234,18 @@ Libraries
52345234
---------
52355235

52365236
* Stabilized APIs:
5237-
* [`str::encode_utf16`][] (renamed from `utf16_units`)
5238-
* [`str::EncodeUtf16`][] (renamed from `Utf16Units`)
5237+
* [`str::encode_utf16`] (renamed from `utf16_units`)
5238+
* [`str::EncodeUtf16`] (renamed from `Utf16Units`)
52395239
* [`Ref::map`]
52405240
* [`RefMut::map`]
52415241
* [`ptr::drop_in_place`]
52425242
* [`time::Instant`]
52435243
* [`time::SystemTime`]
52445244
* [`Instant::now`]
5245-
* [`Instant::duration_since`][] (renamed from `duration_from_earlier`)
5245+
* [`Instant::duration_since`] (renamed from `duration_from_earlier`)
52465246
* [`Instant::elapsed`]
52475247
* [`SystemTime::now`]
5248-
* [`SystemTime::duration_since`][] (renamed from `duration_from_earlier`)
5248+
* [`SystemTime::duration_since`] (renamed from `duration_from_earlier`)
52495249
* [`SystemTime::elapsed`]
52505250
* Various `Add`/`Sub` impls for `Time` and `SystemTime`
52515251
* [`SystemTimeError`]
@@ -5432,8 +5432,8 @@ Libraries
54325432

54335433
* Stabilized APIs
54345434
* `Path`
5435-
* [`Path::strip_prefix`][] (renamed from relative_from)
5436-
* [`path::StripPrefixError`][] (new error type returned from strip_prefix)
5435+
* [`Path::strip_prefix`] (renamed from relative_from)
5436+
* [`path::StripPrefixError`] (new error type returned from strip_prefix)
54375437
* `Ipv4Addr`
54385438
* [`Ipv4Addr::is_loopback`]
54395439
* [`Ipv4Addr::is_private`]
@@ -5646,7 +5646,7 @@ Libraries
56465646

56475647
* Stabilized APIs:
56485648
[`Read::read_exact`],
5649-
[`ErrorKind::UnexpectedEof`][] (renamed from `UnexpectedEOF`),
5649+
[`ErrorKind::UnexpectedEof`] (renamed from `UnexpectedEOF`),
56505650
[`fs::DirBuilder`], [`fs::DirBuilder::new`],
56515651
[`fs::DirBuilder::recursive`], [`fs::DirBuilder::create`],
56525652
[`os::unix::fs::DirBuilderExt`],
@@ -5659,11 +5659,11 @@ Libraries
56595659
[`collections::hash_set::HashSet::drain`],
56605660
[`collections::binary_heap::Drain`],
56615661
[`collections::binary_heap::BinaryHeap::drain`],
5662-
[`Vec::extend_from_slice`][] (renamed from `push_all`),
5662+
[`Vec::extend_from_slice`] (renamed from `push_all`),
56635663
[`Mutex::get_mut`], [`Mutex::into_inner`], [`RwLock::get_mut`],
56645664
[`RwLock::into_inner`],
5665-
[`Iterator::min_by_key`][] (renamed from `min_by`),
5666-
[`Iterator::max_by_key`][] (renamed from `max_by`).
5665+
[`Iterator::min_by_key`] (renamed from `min_by`),
5666+
[`Iterator::max_by_key`] (renamed from `max_by`).
56675667
* The [core library][1.6co] is stable, as are most of its APIs.
56685668
* [The `assert_eq!` macro supports arguments that don't implement
56695669
`Sized`][1.6ae], such as arrays. In this way it behaves more like

src/doc/unstable-book/src/language-features/lang-items.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
188188

189189
In many cases, you may need to manually link to the `compiler_builtins` crate
190190
when building a `no_std` binary. You may observe this via linker error messages
191-
such as "```undefined reference to `__rust_probestack'```". Using this crate
192-
also requires enabling the library feature `compiler_builtins_lib`. You can read
193-
more about this [here][compiler-builtins-lib].
194-
195-
[compiler-builtins-lib]: ../library-features/compiler-builtins-lib.md
191+
such as "```undefined reference to `__rust_probestack'```".
196192

197193
## More about the language items
198194

src/doc/unstable-book/src/library-features/compiler-builtins-lib.md

-35
This file was deleted.

src/liballoc/collections/binary_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ impl<T> FusedIterator for Iter<'_, T> {}
10941094

10951095
/// An owning iterator over the elements of a `BinaryHeap`.
10961096
///
1097-
/// This `struct` is created by the [`into_iter`] method on [`BinaryHeap`][`BinaryHeap`]
1097+
/// This `struct` is created by the [`into_iter`] method on [`BinaryHeap`]
10981098
/// (provided by the `IntoIterator` trait). See its documentation for more.
10991099
///
11001100
/// [`into_iter`]: struct.BinaryHeap.html#method.into_iter

src/liballoc/collections/btree/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
283283

284284
/// An owning iterator over the entries of a `BTreeMap`.
285285
///
286-
/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`][`BTreeMap`]
286+
/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`]
287287
/// (provided by the `IntoIterator` trait). See its documentation for more.
288288
///
289289
/// [`into_iter`]: struct.BTreeMap.html#method.into_iter

src/liballoc/collections/btree/node.rs

+30-24
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
493493

494494
/// Returns a raw ptr to avoid asserting exclusive access to the entire node.
495495
fn as_leaf_mut(&mut self) -> *mut LeafNode<K, V> {
496-
// We are mutable, so we cannot be the root, so accessing this as a leaf is okay.
496+
// We are mutable, so we cannot be the shared root, so accessing this as a leaf is okay.
497497
self.node.as_ptr()
498498
}
499499

@@ -514,33 +514,37 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
514514
// but we want to avoid that run-time check.
515515
// Instead, we create a slice pointing into the node whenever possible.
516516
// We can sometimes do this even for the shared root, as the slice will be
517-
// empty. We cannot *always* do this because if the type is too highly
518-
// aligned, the offset of `keys` in a "full node" might be outside the bounds
519-
// of the header! So we do an alignment check first, that will be
520-
// evaluated at compile-time, and only do any run-time check in the rare case
521-
// that the alignment is very big.
522-
if mem::align_of::<K>() > mem::align_of::<LeafNode<(), ()>>() && self.is_shared_root() {
517+
// empty and `NodeHeader` contains an empty `keys_start` array.
518+
// We cannot *always* do this because:
519+
// - `keys_start` is not correctly typed because we want `NodeHeader`'s size to
520+
// not depend on the alignment of `K` (needed because `as_header` should be safe).
521+
// For this reason, `NodeHeader` has this `K2` parameter (that's usually `()`
522+
// and hence just adds a size-0-align-1 field, not affecting layout).
523+
// If the correctly typed header is more highly aligned than the allocated header,
524+
// we cannot transmute safely.
525+
// - Even if we can transmute, the offset of a correctly typed `keys_start` might
526+
// be different and outside the bounds of the allocated header!
527+
// So we do an alignment check and a size check first, that will be evaluated
528+
// at compile-time, and only do any run-time check in the rare case that
529+
// the compile-time checks signal danger.
530+
if (mem::align_of::<NodeHeader<K, V, K>>() > mem::align_of::<NodeHeader<K, V>>()
531+
|| mem::size_of::<NodeHeader<K, V, K>>() != mem::size_of::<NodeHeader<K, V>>())
532+
&& self.is_shared_root()
533+
{
523534
&[]
524535
} else {
525-
// Thanks to the alignment check above, we know that `keys` will be
536+
// If we are a `LeafNode<K, V>`, we can always transmute to
537+
// `NodeHeader<K, V, K>` and `keys_start` always has the same offset
538+
// as the actual `keys`.
539+
// Thanks to the checks above, we know that we can transmute to
540+
// `NodeHeader<K, V, K>` and that `keys_start` will be
526541
// in-bounds of some allocation even if this is the shared root!
527542
// (We might be one-past-the-end, but that is allowed by LLVM.)
528-
// Getting the pointer is tricky though. `NodeHeader` does not have a `keys`
529-
// field because we want its size to not depend on the alignment of `K`
530-
// (needed because `as_header` should be safe). We cannot call `as_leaf`
531-
// because we might be the shared root.
532-
// For this reason, `NodeHeader` has this `K2` parameter (that's usually `()`
533-
// and hence just adds a size-0-align-1 field, not affecting layout).
534-
// We know that we can transmute `NodeHeader<K, V, ()>` to `NodeHeader<K, V, K>`
535-
// because we did the alignment check above, and hence `NodeHeader<K, V, K>`
536-
// is not bigger than `NodeHeader<K, V, ()>`! Then we can use `NodeHeader<K, V, K>`
543+
// Thus we can use `NodeHeader<K, V, K>`
537544
// to compute the pointer where the keys start.
538545
// This entire hack will become unnecessary once
539546
// <https://github.com/rust-lang/rfcs/pull/2582> lands, then we can just take a raw
540547
// pointer to the `keys` field of `*const InternalNode<K, V>`.
541-
542-
// This is a non-debug-assert because it can be completely compile-time evaluated.
543-
assert!(mem::size_of::<NodeHeader<K, V>>() == mem::size_of::<NodeHeader<K, V, K>>());
544548
let header = self.as_header() as *const _ as *const NodeHeader<K, V, K>;
545549
let keys = unsafe { &(*header).keys_start as *const _ as *const K };
546550
unsafe { slice::from_raw_parts(keys, self.len()) }
@@ -549,7 +553,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
549553

550554
fn into_val_slice(self) -> &'a [V] {
551555
debug_assert!(!self.is_shared_root());
552-
// We cannot be the root, so `as_leaf` is okay
556+
// We cannot be the shared root, so `as_leaf` is okay
553557
unsafe { slice::from_raw_parts(MaybeUninit::first_ptr(&self.as_leaf().vals), self.len()) }
554558
}
555559

@@ -567,9 +571,11 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
567571
}
568572

569573
fn into_key_slice_mut(mut self) -> &'a mut [K] {
570-
// Same as for `into_key_slice` above, we try to avoid a run-time check
571-
// (the alignment comparison will usually be performed at compile-time).
572-
if mem::align_of::<K>() > mem::align_of::<LeafNode<(), ()>>() && self.is_shared_root() {
574+
// Same as for `into_key_slice` above, we try to avoid a run-time check.
575+
if (mem::align_of::<NodeHeader<K, V, K>>() > mem::align_of::<NodeHeader<K, V>>()
576+
|| mem::size_of::<NodeHeader<K, V, K>>() != mem::size_of::<NodeHeader<K, V>>())
577+
&& self.is_shared_root()
578+
{
573579
&mut []
574580
} else {
575581
unsafe {

src/liballoc/collections/btree/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
8383

8484
/// An owning iterator over the items of a `BTreeSet`.
8585
///
86-
/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`][`BTreeSet`]
86+
/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`]
8787
/// (provided by the `IntoIterator` trait). See its documentation for more.
8888
///
8989
/// [`BTreeSet`]: struct.BTreeSet.html

src/liballoc/collections/linked_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
105105

106106
/// An owning iterator over the elements of a `LinkedList`.
107107
///
108-
/// This `struct` is created by the [`into_iter`] method on [`LinkedList`][`LinkedList`]
108+
/// This `struct` is created by the [`into_iter`] method on [`LinkedList`]
109109
/// (provided by the `IntoIterator` trait). See its documentation for more.
110110
///
111111
/// [`into_iter`]: struct.LinkedList.html#method.into_iter

src/liballoc/collections/vec_deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,7 @@ impl<T> FusedIterator for IterMut<'_, T> {}
24742474

24752475
/// An owning iterator over the elements of a `VecDeque`.
24762476
///
2477-
/// This `struct` is created by the [`into_iter`] method on [`VecDeque`][`VecDeque`]
2477+
/// This `struct` is created by the [`into_iter`] method on [`VecDeque`]
24782478
/// (provided by the `IntoIterator` trait). See its documentation for more.
24792479
///
24802480
/// [`into_iter`]: struct.VecDeque.html#method.into_iter

src/liballoc/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@
330330
//!
331331
//! Additionally, the return value of this function is [`fmt::Result`] which is a
332332
//! type alias of [`Result`]`<(), `[`std::fmt::Error`]`>`. Formatting implementations
333-
//! should ensure that they propagate errors from the [`Formatter`][`Formatter`] (e.g., when
333+
//! should ensure that they propagate errors from the [`Formatter`] (e.g., when
334334
//! calling [`write!`]). However, they should never return errors spuriously. That
335335
//! is, a formatting implementation must and may only return an error if the
336336
//! passed-in [`Formatter`] returns an error. This is because, contrary to what

src/liballoc/slice.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ impl<T> [T] {
450450
// and `rem` is the remaining part of `n`.
451451

452452
// Using `Vec` to access `set_len()`.
453-
let mut buf = Vec::with_capacity(self.len().checked_mul(n).expect("capacity overflow"));
453+
let capacity = self.len().checked_mul(n).expect("capacity overflow");
454+
let mut buf = Vec::with_capacity(capacity);
454455

455456
// `2^expn` repetition is done by doubling `buf` `expn`-times.
456457
buf.extend(self);
@@ -476,7 +477,7 @@ impl<T> [T] {
476477

477478
// `rem` (`= n - 2^expn`) repetition is done by copying
478479
// first `rem` repetitions from `buf` itself.
479-
let rem_len = self.len() * n - buf.len(); // `self.len() * rem`
480+
let rem_len = capacity - buf.len(); // `self.len() * rem`
480481
if rem_len > 0 {
481482
// `buf.extend(buf[0 .. rem_len])`:
482483
unsafe {
@@ -487,8 +488,7 @@ impl<T> [T] {
487488
rem_len,
488489
);
489490
// `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
490-
let buf_cap = buf.capacity();
491-
buf.set_len(buf_cap);
491+
buf.set_len(capacity);
492492
}
493493
}
494494
buf

0 commit comments

Comments
 (0)