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

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

-7
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

+42-4
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

+1-1
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

+36-4
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

+2
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

+2-2
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# `s390x-unknown-linux-gnu`
2+
3+
**Tier: 2 (with Host Tools)**
4+
5+
IBM z/Architecture (s390x) targets (including IBM Z and LinuxONE) running Linux.
6+
7+
## Target maintainers
8+
9+
- Ulrich Weigand, <[email protected]>, [@uweigand](https://github.com/uweigand)
10+
- Josh Stone, <[email protected]>, [@cuviper](https://github.com/cuviper)
11+
12+
## Requirements
13+
14+
This target requires:
15+
16+
* Linux Kernel version 3.2 or later
17+
* glibc 2.17 or later
18+
19+
Code generated by the target uses the z/Architecture ISA assuming a minimum
20+
architecture level of z10 (Eighth Edition of the z/Architecture Principles
21+
of Operation), and is compliant with the s390x ELF ABI.
22+
23+
Reference material:
24+
25+
* [z/Architecture Principles of Operation][s390x-isa]
26+
* [z/Architecture ELF Application Binary Interface][s390x-abi]
27+
28+
[s390x-isa]: https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf
29+
[s390x-abi]: https://github.com/IBM/s390x-abi
30+
31+
## Building the target
32+
33+
This target is distributed through `rustup`, and otherwise requires no
34+
special configuration.
35+
36+
If you need to build your own Rust for some reason though, the target can be
37+
enabled in `config.toml`. For example:
38+
39+
```toml
40+
[build]
41+
target = ["s390x-unknown-linux-gnu"]
42+
```
43+
44+
## Building Rust programs
45+
46+
On a s390x Linux host, the `s390x-unknown-linux-gnu` target should be
47+
automatically installed and used by default.
48+
49+
On a non-s390x host, add the target:
50+
51+
```bash
52+
rustup target add s390x-unknown-linux-gnu
53+
```
54+
55+
Then cross compile crates with:
56+
57+
```bash
58+
cargo build --target s390x-unknown-linux-gnu
59+
```
60+
61+
## Testing
62+
63+
There are no special requirements for testing and running the target.
64+
For testing cross builds on the host, please refer to the "Cross-compilation
65+
toolchains and C code" section below.
66+
67+
## Cross-compilation toolchains and C code
68+
69+
Rust code built using the target is compatible with C code compiled with
70+
GCC or Clang using the `s390x-unknown-linux-gnu` target triple (via either
71+
native or cross-compilation).
72+
73+
On Ubuntu, a s390x cross-toolchain can be installed with:
74+
75+
```bash
76+
apt install gcc-s390x-linux-gnu g++-s390x-linux-gnu libc6-dev-s390x-cross
77+
```
78+
79+
Depending on your system, you may need to configure the target to use the GNU
80+
GCC linker. To use it, add the following to your `.cargo/config.toml`:
81+
82+
```toml
83+
[target.s390x-unknown-linux-gnu]
84+
linker = "s390x-linux-gnu-gcc"
85+
```
86+
87+
If your `s390x-linux-gnu-*` toolchain is not in your `PATH` you may need to
88+
configure additional settings:
89+
90+
```toml
91+
[target.s390x-unknown-linux-gnu]
92+
# Adjust the paths to point at your toolchain
93+
cc = "/TOOLCHAIN_PATH/bin/s390x-linux-gnu-gcc"
94+
cxx = "/TOOLCHAIN_PATH/bin/s390x-linux-gnu-g++"
95+
ar = "/TOOLCHAIN_PATH/bin/s390x-linux-gnu-ar"
96+
ranlib = "/TOOLCHAIN_PATH/bin/s390x-linux-gnu-ranlib"
97+
linker = "/TOOLCHAIN_PATH/bin/s390x-linux-gnu-gcc"
98+
```
99+
100+
To test cross compiled binaries on a non-s390x host, you can use
101+
[`qemu`](https://www.qemu.org/docs/master/system/target-s390x.html).
102+
On Ubuntu, a s390x emulator can be obtained with:
103+
104+
```bash
105+
apt install qemu-system-s390x
106+
```
107+
108+
Then, in `.cargo/config.toml` set the `runner`:
109+
110+
```toml
111+
[target.s390x-unknown-linux-gnu]
112+
runner = "qemu-s390x-static -L /usr/s390x-linux-gnu"
113+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# `s390x-unknown-linux-musl`
2+
3+
**Tier: 3**
4+
5+
IBM z/Architecture (s390x) targets (including IBM Z and LinuxONE) running Linux.
6+
7+
## Target maintainers
8+
9+
- Ulrich Weigand, <[email protected]>, [@uweigand](https://github.com/uweigand)
10+
11+
## Requirements
12+
13+
This target requires:
14+
15+
* Linux Kernel version 3.2 or later
16+
* musl 1.2.3 or later
17+
18+
Code generated by the target uses the z/Architecture ISA assuming a minimum
19+
architecture level of z10 (Eighth Edition of the z/Architecture Principles
20+
of Operation), and is compliant with the s390x ELF ABI.
21+
22+
Reference material:
23+
24+
* [z/Architecture Principles of Operation][s390x-isa]
25+
* [z/Architecture ELF Application Binary Interface][s390x-abi]
26+
27+
[s390x-isa]: https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf
28+
[s390x-abi]: https://github.com/IBM/s390x-abi
29+
30+
## Building the target
31+
32+
Because it is Tier 3, Rust does not yet ship pre-compiled artifacts for this
33+
target.
34+
35+
Therefore, you can build Rust with support for the target by adding it to the
36+
target list in `config.toml`, a sample configuration is shown below.
37+
38+
```toml
39+
[build]
40+
target = ["s390x-unknown-linux-musl"]
41+
```
42+
43+
## Building Rust programs
44+
45+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
46+
this target, you will first need to build Rust with the target enabled (see
47+
"Building the target" above).
48+
49+
## Testing
50+
51+
There are no special requirements for testing and running the target.
52+
For testing cross builds on the host, please refer to the "Cross-compilation
53+
toolchains and C code" section below.
54+
55+
## Cross-compilation toolchains and C code
56+
57+
Rust code built using the target is compatible with C code compiled with
58+
GCC or Clang using the `s390x-unknown-linux-musl` target triple (via either
59+
native or cross-compilation).
60+
61+
Depending on your system, you may need to configure the target to use the GNU
62+
GCC linker. To use it, add the following to your `.cargo/config.toml`:
63+
64+
```toml
65+
[target.s390x-unknown-linux-musl]
66+
linker = "s390x-linux-musl-gcc"
67+
```
68+
69+
If your `s390x-linux-musl-*` toolchain is not in your `PATH` you may need to
70+
configure additional settings:
71+
72+
```toml
73+
[target.s390x-unknown-linux-musl]
74+
# Adjust the paths to point at your toolchain
75+
cc = "/TOOLCHAIN_PATH/bin/s390x-linux-musl-gcc"
76+
cxx = "/TOOLCHAIN_PATH/bin/s390x-linux-musl-g++"
77+
ar = "/TOOLCHAIN_PATH/bin/s390x-linux-musl-ar"
78+
ranlib = "/TOOLCHAIN_PATH/bin/s390x-linux-musl-ranlib"
79+
linker = "/TOOLCHAIN_PATH/bin/s390x-linux-musl-gcc"
80+
```
81+
82+
To test cross compiled binaries on a non-s390x host, you can use
83+
[`qemu`](https://www.qemu.org/docs/master/system/target-s390x.html).

0 commit comments

Comments
 (0)