Skip to content

Commit 93708b1

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 1f1de69 + 8b51863 commit 93708b1

File tree

14 files changed

+118
-13
lines changed

14 files changed

+118
-13
lines changed

alloc/src/collections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,18 +1416,18 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
14161416
///
14171417
/// # Examples
14181418
///
1419-
/// Splitting a map into even and odd keys, reusing the original map:
1420-
///
14211419
/// ```
14221420
/// #![feature(btree_extract_if)]
14231421
/// use std::collections::BTreeMap;
14241422
///
1423+
/// // Splitting a map into even and odd keys, reusing the original map:
14251424
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
14261425
/// let evens: BTreeMap<_, _> = map.extract_if(.., |k, _v| k % 2 == 0).collect();
14271426
/// let odds = map;
14281427
/// assert_eq!(evens.keys().copied().collect::<Vec<_>>(), [0, 2, 4, 6]);
14291428
/// assert_eq!(odds.keys().copied().collect::<Vec<_>>(), [1, 3, 5, 7]);
14301429
///
1430+
/// // Splitting a map into low and high halves, reusing the original map:
14311431
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
14321432
/// let low: BTreeMap<_, _> = map.extract_if(0..4, |_k, _v| true).collect();
14331433
/// let high = map;

alloc/src/collections/btree/set.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,21 +1201,21 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
12011201
/// [`retain`]: BTreeSet::retain
12021202
/// # Examples
12031203
///
1204-
/// Splitting a set into even and odd values, reusing the original set:
1205-
///
12061204
/// ```
12071205
/// #![feature(btree_extract_if)]
12081206
/// use std::collections::BTreeSet;
12091207
///
1208+
/// // Splitting a set into even and odd values, reusing the original set:
12101209
/// let mut set: BTreeSet<i32> = (0..8).collect();
12111210
/// let evens: BTreeSet<_> = set.extract_if(.., |v| v % 2 == 0).collect();
12121211
/// let odds = set;
12131212
/// assert_eq!(evens.into_iter().collect::<Vec<_>>(), vec![0, 2, 4, 6]);
12141213
/// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 7]);
12151214
///
1216-
/// let mut map: BTreeSet<i32> = (0..8).collect();
1217-
/// let low: BTreeSet<_> = map.extract_if(0..4, |_v| true).collect();
1218-
/// let high = map;
1215+
/// // Splitting a set into low and high halves, reusing the original set:
1216+
/// let mut set: BTreeSet<i32> = (0..8).collect();
1217+
/// let low: BTreeSet<_> = set.extract_if(0..4, |_v| true).collect();
1218+
/// let high = set;
12191219
/// assert_eq!(low.into_iter().collect::<Vec<_>>(), [0, 1, 2, 3]);
12201220
/// assert_eq!(high.into_iter().collect::<Vec<_>>(), [4, 5, 6, 7]);
12211221
/// ```

core/src/convert/num.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")
175175
impl_from!(u8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
176176
impl_from!(u8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
177177
impl_from!(u8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
178-
impl_from!(u16 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
179178
impl_from!(u16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
180179
impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
181180
impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

core/src/fmt/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,20 @@ pub use macros::Debug;
928928
/// [tostring]: ../../std/string/trait.ToString.html
929929
/// [tostring_function]: ../../std/string/trait.ToString.html#tymethod.to_string
930930
///
931+
/// # Completeness and parseability
932+
///
933+
/// `Display` for a type might not necessarily be a lossless or complete representation of the type.
934+
/// It may omit internal state, precision, or other information the type does not consider important
935+
/// for user-facing output, as determined by the type. As such, the output of `Display` might not be
936+
/// possible to parse, and even if it is, the result of parsing might not exactly match the original
937+
/// value.
938+
///
939+
/// However, if a type has a lossless `Display` implementation whose output is meant to be
940+
/// conveniently machine-parseable and not just meant for human consumption, then the type may wish
941+
/// to accept the same format in `FromStr`, and document that usage. Having both `Display` and
942+
/// `FromStr` implementations where the result of `Display` cannot be parsed with `FromStr` may
943+
/// surprise users.
944+
///
931945
/// # Internationalization
932946
///
933947
/// Because a type can only have one `Display` implementation, it is often preferable

core/src/primitive_docs.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,18 @@ mod prim_i64 {}
14281428
#[rustc_doc_primitive = "i128"]
14291429
//
14301430
/// The 128-bit signed integer type.
1431+
///
1432+
/// # ABI compatibility
1433+
///
1434+
/// Rust's `i128` is expected to be ABI-compatible with C's `__int128` on platforms where the type
1435+
/// is available, which includes most 64-bit architectures. If any platforms that do not specify
1436+
/// `__int128` are updated to introduce it, the Rust `i128` ABI on relevant targets will be changed
1437+
/// to match.
1438+
///
1439+
/// It is important to note that in C, `__int128` is _not_ the same as `_BitInt(128)`, and the two
1440+
/// types are allowed to have different ABIs. In particular, on x86, `__int128` and `_BitInt(128)`
1441+
/// do not use the same alignment. `i128` is intended to always match `__int128` and does not
1442+
/// attempt to match `_BitInt(128)` on platforms without `__int128`.
14311443
#[stable(feature = "i128", since = "1.26.0")]
14321444
mod prim_i128 {}
14331445

@@ -1458,6 +1470,8 @@ mod prim_u64 {}
14581470
#[rustc_doc_primitive = "u128"]
14591471
//
14601472
/// The 128-bit unsigned integer type.
1473+
///
1474+
/// Please see [the documentation for `i128`](prim@i128) for information on ABI compatibility.
14611475
#[stable(feature = "i128", since = "1.26.0")]
14621476
mod prim_u128 {}
14631477

core/src/str/traits.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,20 @@ unsafe impl SliceIndex<str> for ops::RangeToInclusive<usize> {
756756
/// parse an `i32` with `FromStr`, but not a `&i32`. You can parse a struct that
757757
/// contains an `i32`, but not one that contains an `&i32`.
758758
///
759+
/// # Input format and round-tripping
760+
///
761+
/// The input format expected by a type's `FromStr` implementation depends on the type. Check the
762+
/// type's documentation for the input formats it knows how to parse. Note that the input format of
763+
/// a type's `FromStr` implementation might not necessarily accept the output format of its
764+
/// `Display` implementation, and even if it does, the `Display` implementation may not be lossless
765+
/// so the round-trip may lose information.
766+
///
767+
/// However, if a type has a lossless `Display` implementation whose output is meant to be
768+
/// conveniently machine-parseable and not just meant for human consumption, then the type may wish
769+
/// to accept the same format in `FromStr`, and document that usage. Having both `Display` and
770+
/// `FromStr` implementations where the result of `Display` cannot be parsed with `FromStr` may
771+
/// surprise users.
772+
///
759773
/// # Examples
760774
///
761775
/// Basic implementation of `FromStr` on an example `Point` type:

coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#![feature(duration_constructors)]
3131
#![feature(duration_constructors_lite)]
3232
#![feature(error_generic_member_access)]
33+
#![feature(exact_div)]
3334
#![feature(exact_size_is_empty)]
3435
#![feature(extend_one)]
3536
#![feature(extern_types)]

coretests/tests/num/int_macros.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,5 +683,43 @@ macro_rules! int_module {
683683
assert_eq_const_safe!($T: <$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW3), 0);
684684
}
685685
}
686+
687+
const EXACT_DIV_SUCCESS_DIVIDEND1: $T = 42;
688+
const EXACT_DIV_SUCCESS_DIVISOR1: $T = 6;
689+
const EXACT_DIV_SUCCESS_QUOTIENT1: $T = 7;
690+
const EXACT_DIV_SUCCESS_DIVIDEND2: $T = 18;
691+
const EXACT_DIV_SUCCESS_DIVISOR2: $T = 3;
692+
const EXACT_DIV_SUCCESS_QUOTIENT2: $T = 6;
693+
const EXACT_DIV_SUCCESS_DIVIDEND3: $T = -91;
694+
const EXACT_DIV_SUCCESS_DIVISOR3: $T = 13;
695+
const EXACT_DIV_SUCCESS_QUOTIENT3: $T = -7;
696+
const EXACT_DIV_SUCCESS_DIVIDEND4: $T = -57;
697+
const EXACT_DIV_SUCCESS_DIVISOR4: $T = -3;
698+
const EXACT_DIV_SUCCESS_QUOTIENT4: $T = 19;
699+
700+
test_runtime_and_compiletime! {
701+
fn test_exact_div() {
702+
// 42 / 6
703+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), Some(EXACT_DIV_SUCCESS_QUOTIENT1));
704+
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), EXACT_DIV_SUCCESS_QUOTIENT1);
705+
706+
// 18 / 3
707+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), Some(EXACT_DIV_SUCCESS_QUOTIENT2));
708+
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), EXACT_DIV_SUCCESS_QUOTIENT2);
709+
710+
// -91 / 13
711+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND3, EXACT_DIV_SUCCESS_DIVISOR3), Some(EXACT_DIV_SUCCESS_QUOTIENT3));
712+
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND3, EXACT_DIV_SUCCESS_DIVISOR3), EXACT_DIV_SUCCESS_QUOTIENT3);
713+
714+
// -57 / -3
715+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND4, EXACT_DIV_SUCCESS_DIVISOR4), Some(EXACT_DIV_SUCCESS_QUOTIENT4));
716+
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND4, EXACT_DIV_SUCCESS_DIVISOR4), EXACT_DIV_SUCCESS_QUOTIENT4);
717+
718+
// failures
719+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(1, 2), None);
720+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(<$T>::MIN, -1), None);
721+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(0, 0), None);
722+
}
723+
}
686724
};
687725
}

coretests/tests/num/uint_macros.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,5 +516,28 @@ macro_rules! uint_module {
516516
assert_eq_const_safe!($T: <$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW3), 0);
517517
}
518518
}
519+
520+
const EXACT_DIV_SUCCESS_DIVIDEND1: $T = 42;
521+
const EXACT_DIV_SUCCESS_DIVISOR1: $T = 6;
522+
const EXACT_DIV_SUCCESS_QUOTIENT1: $T = 7;
523+
const EXACT_DIV_SUCCESS_DIVIDEND2: $T = 18;
524+
const EXACT_DIV_SUCCESS_DIVISOR2: $T = 3;
525+
const EXACT_DIV_SUCCESS_QUOTIENT2: $T = 6;
526+
527+
test_runtime_and_compiletime! {
528+
fn test_exact_div() {
529+
// 42 / 6
530+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), Some(EXACT_DIV_SUCCESS_QUOTIENT1));
531+
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), EXACT_DIV_SUCCESS_QUOTIENT1);
532+
533+
// 18 / 3
534+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), Some(EXACT_DIV_SUCCESS_QUOTIENT2));
535+
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), EXACT_DIV_SUCCESS_QUOTIENT2);
536+
537+
// failures
538+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(1, 2), None);
539+
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(0, 0), None);
540+
}
541+
}
519542
};
520543
}

std/src/ffi/os_str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ impl OsString {
137137
#[stable(feature = "rust1", since = "1.0.0")]
138138
#[must_use]
139139
#[inline]
140-
pub fn new() -> OsString {
140+
#[rustc_const_unstable(feature = "const_pathbuf_osstring_new", issue = "141520")]
141+
pub const fn new() -> OsString {
141142
OsString { inner: Buf::from_string(String::new()) }
142143
}
143144

0 commit comments

Comments
 (0)