Skip to content

Commit 7b9905e

Browse files
committed
Auto merge of #149370 - Zalathar:rollup-6fkk5x4, r=Zalathar
Rollup of 8 pull requests Successful merges: - #149238 (float::clamp: make treatment of signed zeros unspecified) - #149270 (implement `Iterator::{exactly_one, collect_array}`) - #149295 (Suggest _bytes versions of endian-converting methods) - #149332 (fix rustdoc search says “Consider searching for "null" instead.” #149324) - #149349 (Fix typo in comment.) - #149353 (Tidying up UI tests [3/N]) - #149355 (Document that `build.description` affects symbol mangling and crate IDs) - #149360 (Enable CI download for windows-gnullvm) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a417515 + 7b50aa6 commit 7b9905e

File tree

35 files changed

+226
-69
lines changed

35 files changed

+226
-69
lines changed

bootstrap.example.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@
220220
# which is also used in places like debuginfo `DW_AT_producer`. This may be useful for
221221
# supplementary build information, like distro-specific package versions.
222222
#
223+
# IMPORTANT: Changing this value changes crate IDs and symbol name mangling, making
224+
# compiled artifacts incompatible. PGO profiles cannot be reused across different
225+
# descriptions, and incremental compilation caches are invalidated. Keep this value
226+
# consistent when reusing build artifacts.
227+
#
223228
# The Rust compiler will differentiate between versions of itself, including
224229
# based on this string, which means that if you wish to be compatible with
225230
# upstream Rust you need to set this to "". However, note that if you set this to "" but

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ impl MetadataLoader for DefaultMetadataLoader {
8686
format!("failed to parse aix dylib '{}': {}", path.display(), e)
8787
})?;
8888

89-
match archive.members().exactly_one() {
89+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
90+
match Itertools::exactly_one(archive.members()) {
9091
Ok(lib) => {
9192
let lib = lib.map_err(|e| {
9293
format!("failed to parse aix dylib '{}': {}", path.display(), e)

library/core/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ impl<'a> Formatter<'a> {
625625
//
626626
// 2) Placeholders representation (e.g. format_args!("hello {name}\n"))
627627
// ┌────────────────────────────────┐
628-
// template: │ *const u8 │ ─▷ b"\x06hello \x80\x01\n\x00"
628+
// template: │ *const u8 │ ─▷ b"\x06hello \xC0\x01\n\x00"
629629
// ├────────────────────────────────┤
630630
// args: │ &'a [Argument<'a>; _] 0│ (lower bit is 0 due to alignment of Argument type)
631631
// └────────────────────────────────┘

library/core/src/iter/traits/iterator.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4034,6 +4034,62 @@ pub trait Iterator {
40344034
{
40354035
unreachable!("Always specialized");
40364036
}
4037+
4038+
/// Checks if the iterator contains *exactly* one element.
4039+
/// If so, returns this one element.
4040+
///
4041+
/// See also [`collect_array`](Iterator::collect_array) for lengths other than `1`.
4042+
///
4043+
/// # Examples
4044+
///
4045+
/// ```
4046+
/// #![feature(exact_length_collection)]
4047+
///
4048+
/// assert_eq!([1].into_iter().exactly_one(), Some(1));
4049+
/// assert_eq!([].into_iter().exactly_one(), None::<()>);
4050+
///
4051+
/// // There is exactly one even integer in the array:
4052+
/// assert_eq!([1, 2, 3].into_iter().filter(|x| x % 2 == 0).exactly_one(), Some(2));
4053+
/// // But there are two odds, which is too many:
4054+
/// assert_eq!([1, 2, 3].into_iter().filter(|x| x % 2 == 1).exactly_one(), None);
4055+
/// ```
4056+
#[inline]
4057+
#[unstable(feature = "exact_length_collection", issue = "149266")]
4058+
fn exactly_one(self) -> Option<Self::Item>
4059+
where
4060+
Self: Sized,
4061+
{
4062+
self.collect_array::<1>().map(|[i]| i)
4063+
}
4064+
4065+
/// Checks if an iterator has *exactly* `N` elements.
4066+
/// If so, returns those `N` elements in an array.
4067+
///
4068+
/// See also [`exactly_one`](Iterator::exactly_one) when expecting a single element.
4069+
///
4070+
/// # Examples
4071+
///
4072+
/// ```
4073+
/// #![feature(exact_length_collection)]
4074+
///
4075+
/// assert_eq!([1, 2, 3, 4].into_iter().collect_array(), Some([1, 2, 3, 4]));
4076+
/// assert_eq!([1, 2].into_iter().chain([3, 4]).collect_array(), Some([1, 2, 3, 4]));
4077+
///
4078+
/// // Iterator contains too few elements:
4079+
/// assert_eq!([1, 2].into_iter().collect_array::<4>(), None);
4080+
/// // Iterator contains too many elements:
4081+
/// assert_eq!([1, 2, 3, 4, 5].into_iter().collect_array::<4>(), None);
4082+
/// // Taking 4 makes it work again:
4083+
/// assert_eq!([1, 2, 3, 4, 5].into_iter().take(4).collect_array(), Some([1, 2, 3, 4]));
4084+
/// ```
4085+
#[inline]
4086+
#[unstable(feature = "exact_length_collection", issue = "149266")]
4087+
fn collect_array<const N: usize>(mut self) -> Option<[Self::Item; N]>
4088+
where
4089+
Self: Sized,
4090+
{
4091+
self.next_chunk().ok().filter(|_| self.next().is_none())
4092+
}
40374093
}
40384094

40394095
trait SpecIterEq<B: Iterator>: Iterator {

library/core/src/num/f128.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,8 @@ impl f128 {
12381238
/// less than `min`. Otherwise this returns `self`.
12391239
///
12401240
/// Note that this function returns NaN if the initial value was NaN as
1241-
/// well.
1241+
/// well. If the result is zero and among the three inputs `self`, `min`, and `max` there are
1242+
/// zeros with different sign, either `0.0` or `-0.0` is returned non-deterministically.
12421243
///
12431244
/// # Panics
12441245
///
@@ -1255,6 +1256,12 @@ impl f128 {
12551256
/// assert!((0.0f128).clamp(-2.0, 1.0) == 0.0);
12561257
/// assert!((2.0f128).clamp(-2.0, 1.0) == 1.0);
12571258
/// assert!((f128::NAN).clamp(-2.0, 1.0).is_nan());
1259+
///
1260+
/// // These always returns zero, but the sign (which is ignored by `==`) is non-deterministic.
1261+
/// assert!((0.0f128).clamp(-0.0, -0.0) == 0.0);
1262+
/// assert!((1.0f128).clamp(-0.0, 0.0) == 0.0);
1263+
/// // This is definitely a negative zero.
1264+
/// assert!((-1.0f128).clamp(-0.0, 1.0).is_sign_negative());
12581265
/// # }
12591266
/// ```
12601267
#[inline]

library/core/src/num/f16.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,8 @@ impl f16 {
12171217
/// less than `min`. Otherwise this returns `self`.
12181218
///
12191219
/// Note that this function returns NaN if the initial value was NaN as
1220-
/// well.
1220+
/// well. If the result is zero and among the three inputs `self`, `min`, and `max` there are
1221+
/// zeros with different sign, either `0.0` or `-0.0` is returned non-deterministically.
12211222
///
12221223
/// # Panics
12231224
///
@@ -1233,6 +1234,12 @@ impl f16 {
12331234
/// assert!((0.0f16).clamp(-2.0, 1.0) == 0.0);
12341235
/// assert!((2.0f16).clamp(-2.0, 1.0) == 1.0);
12351236
/// assert!((f16::NAN).clamp(-2.0, 1.0).is_nan());
1237+
///
1238+
/// // These always returns zero, but the sign (which is ignored by `==`) is non-deterministic.
1239+
/// assert!((0.0f16).clamp(-0.0, -0.0) == 0.0);
1240+
/// assert!((1.0f16).clamp(-0.0, 0.0) == 0.0);
1241+
/// // This is definitely a negative zero.
1242+
/// assert!((-1.0f16).clamp(-0.0, 1.0).is_sign_negative());
12361243
/// # }
12371244
/// ```
12381245
#[inline]

library/core/src/num/f32.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,8 @@ impl f32 {
13971397
/// less than `min`. Otherwise this returns `self`.
13981398
///
13991399
/// Note that this function returns NaN if the initial value was NaN as
1400-
/// well.
1400+
/// well. If the result is zero and among the three inputs `self`, `min`, and `max` there are
1401+
/// zeros with different sign, either `0.0` or `-0.0` is returned non-deterministically.
14011402
///
14021403
/// # Panics
14031404
///
@@ -1410,6 +1411,12 @@ impl f32 {
14101411
/// assert!((0.0f32).clamp(-2.0, 1.0) == 0.0);
14111412
/// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
14121413
/// assert!((f32::NAN).clamp(-2.0, 1.0).is_nan());
1414+
///
1415+
/// // These always returns zero, but the sign (which is ignored by `==`) is non-deterministic.
1416+
/// assert!((0.0f32).clamp(-0.0, -0.0) == 0.0);
1417+
/// assert!((1.0f32).clamp(-0.0, 0.0) == 0.0);
1418+
/// // This is definitely a negative zero.
1419+
/// assert!((-1.0f32).clamp(-0.0, 1.0).is_sign_negative());
14131420
/// ```
14141421
#[must_use = "method returns a new number and does not mutate the original value"]
14151422
#[stable(feature = "clamp", since = "1.50.0")]

library/core/src/num/f64.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,8 @@ impl f64 {
13951395
/// less than `min`. Otherwise this returns `self`.
13961396
///
13971397
/// Note that this function returns NaN if the initial value was NaN as
1398-
/// well.
1398+
/// well. If the result is zero and among the three inputs `self`, `min`, and `max` there are
1399+
/// zeros with different sign, either `0.0` or `-0.0` is returned non-deterministically.
13991400
///
14001401
/// # Panics
14011402
///
@@ -1408,6 +1409,12 @@ impl f64 {
14081409
/// assert!((0.0f64).clamp(-2.0, 1.0) == 0.0);
14091410
/// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0);
14101411
/// assert!((f64::NAN).clamp(-2.0, 1.0).is_nan());
1412+
///
1413+
/// // These always returns zero, but the sign (which is ignored by `==`) is non-deterministic.
1414+
/// assert!((0.0f64).clamp(-0.0, -0.0) == 0.0);
1415+
/// assert!((1.0f64).clamp(-0.0, 0.0) == 0.0);
1416+
/// // This is definitely a negative zero.
1417+
/// assert!((-1.0f64).clamp(-0.0, 1.0).is_sign_negative());
14111418
/// ```
14121419
#[must_use = "method returns a new number and does not mutate the original value"]
14131420
#[stable(feature = "clamp", since = "1.50.0")]

library/core/src/num/int_macros.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ macro_rules! int_impl {
372372
///
373373
/// On big endian this is a no-op. On little endian the bytes are swapped.
374374
///
375+
/// See also [from_be_bytes()](Self::from_be_bytes).
376+
///
375377
/// # Examples
376378
///
377379
/// ```
@@ -402,6 +404,8 @@ macro_rules! int_impl {
402404
///
403405
/// On little endian this is a no-op. On big endian the bytes are swapped.
404406
///
407+
/// See also [from_le_bytes()](Self::from_le_bytes).
408+
///
405409
/// # Examples
406410
///
407411
/// ```
@@ -428,9 +432,15 @@ macro_rules! int_impl {
428432
}
429433
}
430434

431-
/// Converts `self` to big endian from the target's endianness.
435+
/// Swaps bytes of `self` on little endian targets.
432436
///
433-
/// On big endian this is a no-op. On little endian the bytes are swapped.
437+
/// On big endian this is a no-op.
438+
///
439+
/// The returned value has the same type as `self`, and will be interpreted
440+
/// as (a potentially different) value of a native-endian
441+
#[doc = concat!("`", stringify!($SelfT), "`.")]
442+
///
443+
/// See [`to_be_bytes()`](Self::to_be_bytes) for a type-safe alternative.
434444
///
435445
/// # Examples
436446
///
@@ -459,9 +469,15 @@ macro_rules! int_impl {
459469
}
460470
}
461471

462-
/// Converts `self` to little endian from the target's endianness.
472+
/// Swaps bytes of `self` on big endian targets.
463473
///
464-
/// On little endian this is a no-op. On big endian the bytes are swapped.
474+
/// On little endian this is a no-op.
475+
///
476+
/// The returned value has the same type as `self`, and will be interpreted
477+
/// as (a potentially different) value of a native-endian
478+
#[doc = concat!("`", stringify!($SelfT), "`.")]
479+
///
480+
/// See [`to_le_bytes()`](Self::to_le_bytes) for a type-safe alternative.
465481
///
466482
/// # Examples
467483
///

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ pub(crate) fn is_ci_llvm_available_for_target(
206206
("aarch64-unknown-linux-gnu", false),
207207
("aarch64-apple-darwin", false),
208208
("aarch64-pc-windows-msvc", false),
209-
("i686-pc-windows-gnu", false),
210209
("i686-pc-windows-msvc", false),
211210
("i686-unknown-linux-gnu", false),
212211
("x86_64-unknown-linux-gnu", true),
@@ -215,9 +214,11 @@ pub(crate) fn is_ci_llvm_available_for_target(
215214
("x86_64-pc-windows-msvc", true),
216215
// tier 2 with host tools
217216
("aarch64-unknown-linux-musl", false),
217+
("aarch64-pc-windows-gnullvm", false),
218218
("arm-unknown-linux-gnueabi", false),
219219
("arm-unknown-linux-gnueabihf", false),
220220
("armv7-unknown-linux-gnueabihf", false),
221+
("i686-pc-windows-gnu", false),
221222
("loongarch64-unknown-linux-gnu", false),
222223
("loongarch64-unknown-linux-musl", false),
223224
("powerpc-unknown-linux-gnu", false),
@@ -226,6 +227,7 @@ pub(crate) fn is_ci_llvm_available_for_target(
226227
("powerpc64le-unknown-linux-musl", false),
227228
("riscv64gc-unknown-linux-gnu", false),
228229
("s390x-unknown-linux-gnu", false),
230+
("x86_64-pc-windows-gnullvm", true),
229231
("x86_64-unknown-freebsd", false),
230232
("x86_64-unknown-illumos", false),
231233
("x86_64-unknown-linux-musl", false),

0 commit comments

Comments
 (0)