Skip to content

Commit e6c1e14

Browse files
committed
Auto merge of rust-lang#133193 - fmease:rollup-v38ayvk, r=fmease
Rollup of 9 pull requests Successful merges: - rust-lang#132758 (Improve `{BTreeMap,HashMap}::get_key_value` docs.) - rust-lang#133180 ([rustdoc] Fix items with generics not having their jump to def link generated) - rust-lang#133181 (Update books) - rust-lang#133182 (const_panic: inline in bootstrap builds to avoid f16/f128 crashes) - rust-lang#133185 (rustdoc-search: use smart binary search in bitmaps) - rust-lang#133186 (Document s390x-unknown-linux targets) - rust-lang#133187 (Add reference annotations for diagnostic attributes) - rust-lang#133191 (rustdoc book: Move `--test-builder(--wrapper)?` docs to unstable section.) - rust-lang#133192 (RELEASES.md: Don't document unstable `--test-build-wrapper`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5926e82 + 56747f3 commit e6c1e14

File tree

45 files changed

+574
-212
lines changed

Some content is hidden

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

45 files changed

+574
-212
lines changed

RELEASES.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,6 @@ Cargo
670670
- [Support `target.<triple>.rustdocflags` officially](https://github.com/rust-lang/cargo/pull/13197/)
671671
- [Stabilize global cache data tracking](https://github.com/rust-lang/cargo/pull/13492/)
672672

673-
<a id="1.78.0-Misc"></a>
674-
675-
Misc
676-
----
677-
678-
- [rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests](https://github.com/rust-lang/rust/pull/114651/)
679-
680673
<a id="1.78.0-Compatibility-Notes"></a>
681674

682675
Compatibility Notes

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

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,20 +677,58 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
677677
}
678678
}
679679

680-
/// Returns the key-value pair corresponding to the supplied key.
680+
/// Returns the key-value pair corresponding to the supplied key. This is
681+
/// potentially useful:
682+
/// - for key types where non-identical keys can be considered equal;
683+
/// - for getting the `&K` stored key value from a borrowed `&Q` lookup key; or
684+
/// - for getting a reference to a key with the same lifetime as the collection.
681685
///
682686
/// The supplied key may be any borrowed form of the map's key type, but the ordering
683687
/// on the borrowed form *must* match the ordering on the key type.
684688
///
685689
/// # Examples
686690
///
687691
/// ```
692+
/// use std::cmp::Ordering;
688693
/// use std::collections::BTreeMap;
689694
///
695+
/// #[derive(Clone, Copy, Debug)]
696+
/// struct S {
697+
/// id: u32,
698+
/// # #[allow(unused)] // prevents a "field `name` is never read" error
699+
/// name: &'static str, // ignored by equality and ordering operations
700+
/// }
701+
///
702+
/// impl PartialEq for S {
703+
/// fn eq(&self, other: &S) -> bool {
704+
/// self.id == other.id
705+
/// }
706+
/// }
707+
///
708+
/// impl Eq for S {}
709+
///
710+
/// impl PartialOrd for S {
711+
/// fn partial_cmp(&self, other: &S) -> Option<Ordering> {
712+
/// self.id.partial_cmp(&other.id)
713+
/// }
714+
/// }
715+
///
716+
/// impl Ord for S {
717+
/// fn cmp(&self, other: &S) -> Ordering {
718+
/// self.id.cmp(&other.id)
719+
/// }
720+
/// }
721+
///
722+
/// let j_a = S { id: 1, name: "Jessica" };
723+
/// let j_b = S { id: 1, name: "Jess" };
724+
/// let p = S { id: 2, name: "Paul" };
725+
/// assert_eq!(j_a, j_b);
726+
///
690727
/// let mut map = BTreeMap::new();
691-
/// map.insert(1, "a");
692-
/// assert_eq!(map.get_key_value(&1), Some((&1, &"a")));
693-
/// assert_eq!(map.get_key_value(&2), None);
728+
/// map.insert(j_a, "Paris");
729+
/// assert_eq!(map.get_key_value(&j_a), Some((&j_a, &"Paris")));
730+
/// assert_eq!(map.get_key_value(&j_b), Some((&j_a, &"Paris"))); // the notable case
731+
/// assert_eq!(map.get_key_value(&p), None);
694732
/// ```
695733
#[stable(feature = "map_get_key_value", since = "1.40.0")]
696734
pub fn get_key_value<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)>

library/core/src/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ pub macro const_panic {
215215
#[noinline]
216216
if const #[track_caller] #[inline] { // Inline this, to prevent codegen
217217
$crate::panic!($const_msg)
218-
} else #[track_caller] { // Do not inline this, it makes perf worse
218+
} else #[track_caller] #[cfg_attr(bootstrap, inline)] { // Do not inline this, it makes perf worse
219219
$crate::panic!($runtime_msg)
220220
}
221221
)

library/std/src/collections/hash/map.rs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,11 @@ where
880880
self.base.get(k)
881881
}
882882

883-
/// Returns the key-value pair corresponding to the supplied key.
883+
/// Returns the key-value pair corresponding to the supplied key. This is
884+
/// potentially useful:
885+
/// - for key types where non-identical keys can be considered equal;
886+
/// - for getting the `&K` stored key value from a borrowed `&Q` lookup key; or
887+
/// - for getting a reference to a key with the same lifetime as the collection.
884888
///
885889
/// The supplied key may be any borrowed form of the map's key type, but
886890
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
@@ -890,11 +894,39 @@ where
890894
///
891895
/// ```
892896
/// use std::collections::HashMap;
897+
/// use std::hash::{Hash, Hasher};
898+
///
899+
/// #[derive(Clone, Copy, Debug)]
900+
/// struct S {
901+
/// id: u32,
902+
/// # #[allow(unused)] // prevents a "field `name` is never read" error
903+
/// name: &'static str, // ignored by equality and hashing operations
904+
/// }
905+
///
906+
/// impl PartialEq for S {
907+
/// fn eq(&self, other: &S) -> bool {
908+
/// self.id == other.id
909+
/// }
910+
/// }
911+
///
912+
/// impl Eq for S {}
913+
///
914+
/// impl Hash for S {
915+
/// fn hash<H: Hasher>(&self, state: &mut H) {
916+
/// self.id.hash(state);
917+
/// }
918+
/// }
919+
///
920+
/// let j_a = S { id: 1, name: "Jessica" };
921+
/// let j_b = S { id: 1, name: "Jess" };
922+
/// let p = S { id: 2, name: "Paul" };
923+
/// assert_eq!(j_a, j_b);
893924
///
894925
/// let mut map = HashMap::new();
895-
/// map.insert(1, "a");
896-
/// assert_eq!(map.get_key_value(&1), Some((&1, &"a")));
897-
/// assert_eq!(map.get_key_value(&2), None);
926+
/// map.insert(j_a, "Paris");
927+
/// assert_eq!(map.get_key_value(&j_a), Some((&j_a, &"Paris")));
928+
/// assert_eq!(map.get_key_value(&j_b), Some((&j_a, &"Paris"))); // the notable case
929+
/// assert_eq!(map.get_key_value(&p), None);
898930
/// ```
899931
#[inline]
900932
#[stable(feature = "map_get_key_value", since = "1.40.0")]

src/doc/nomicon

src/doc/rustc/src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)
7373
- [riscv64gc-unknown-linux-gnu](platform-support/riscv64gc-unknown-linux-gnu.md)
7474
- [riscv64gc-unknown-linux-musl](platform-support/riscv64gc-unknown-linux-musl.md)
75+
- [s390x-unknown-linux-gnu](platform-support/s390x-unknown-linux-gnu.md)
76+
- [s390x-unknown-linux-musl](platform-support/s390x-unknown-linux-musl.md)
7577
- [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md)
7678
- [*-pc-windows-gnullvm](platform-support/pc-windows-gnullvm.md)
7779
- [\*-nto-qnx-\*](platform-support/nto-qnx.md)

src/doc/rustc/src/platform-support.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ target | notes
9999
`powerpc64le-unknown-linux-gnu` | PPC64LE Linux (kernel 3.10, glibc 2.17)
100100
[`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20, glibc 2.29)
101101
[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20, musl 1.2.3)
102-
`s390x-unknown-linux-gnu` | S390x Linux (kernel 3.2, glibc 2.17)
102+
[`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2, glibc 2.17)
103103
`x86_64-unknown-freebsd` | 64-bit FreeBSD
104104
`x86_64-unknown-illumos` | illumos
105105
`x86_64-unknown-linux-musl` | 64-bit Linux with musl 1.2.3
@@ -367,7 +367,7 @@ target | std | host | notes
367367
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
368368
[`riscv64-linux-android`](platform-support/android.md) | | | RISC-V 64-bit Android
369369
[`riscv64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
370-
`s390x-unknown-linux-musl` | | | S390x Linux (kernel 3.2, musl 1.2.3)
370+
[`s390x-unknown-linux-musl`](platform-support/s390x-unknown-linux-musl.md) | | | S390x Linux (kernel 3.2, musl 1.2.3)
371371
`sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux
372372
[`sparc-unknown-none-elf`](./platform-support/sparc-unknown-none-elf.md) | * | | Bare 32-bit SPARC V7+
373373
[`sparc64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/sparc64

0 commit comments

Comments
 (0)