Skip to content

Commit af9fc8f

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 900e66f + fd5d2c6 commit af9fc8f

File tree

21 files changed

+139
-75
lines changed

21 files changed

+139
-75
lines changed

alloc/src/borrow.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,18 @@ where
340340
}
341341
}
342342

343+
// `Cow<'_, T>` can only implement `DerefPure` if `<T::Owned as Borrow<T>>` (and `BorrowMut<T>`) is trusted.
344+
// For now, we restrict `DerefPure for Cow<T>` to `T: Sized` (`T as Borrow<T>` is trusted),
345+
// `str` (`String as Borrow<str>` is trusted) and `[T]` (`Vec<T> as Borrow<[T]>` is trusted).
346+
// In the future, a `BorrowPure<T>` trait analogous to `DerefPure` might generalize this.
343347
#[unstable(feature = "deref_pure_trait", issue = "87121")]
344-
unsafe impl<B: ?Sized + ToOwned> DerefPure for Cow<'_, B> where B::Owned: Borrow<B> {}
348+
unsafe impl<T: Clone> DerefPure for Cow<'_, T> {}
349+
#[cfg(not(no_global_oom_handling))]
350+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
351+
unsafe impl DerefPure for Cow<'_, str> {}
352+
#[cfg(not(no_global_oom_handling))]
353+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
354+
unsafe impl<T: Clone> DerefPure for Cow<'_, [T]> {}
345355

346356
#[stable(feature = "rust1", since = "1.0.0")]
347357
impl<B: ?Sized> Eq for Cow<'_, B> where B: Eq + ToOwned {}

core/src/char/methods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ impl char {
11681168
#[must_use]
11691169
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
11701170
#[rustc_const_stable(feature = "const_char_is_ascii", since = "1.32.0")]
1171+
#[cfg_attr(not(test), rustc_diagnostic_item = "char_is_ascii")]
11711172
#[inline]
11721173
pub const fn is_ascii(&self) -> bool {
11731174
*self as u32 <= 0x7F

core/src/iter/adapters/zip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,21 +556,21 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
556556
/// * `std::iter::ExactSizeIterator::len`
557557
/// * `std::iter::Iterator::__iterator_get_unchecked`
558558
/// * `std::iter::TrustedRandomAccessNoCoerce::size`
559-
/// 5. If `T` is a subtype of `Self`, then `self` is allowed to be coerced
559+
/// 5. If `Self` is a subtype of `T`, then `self` is allowed to be coerced
560560
/// to `T`. If `self` is coerced to `T` after `self.__iterator_get_unchecked(idx)` has already
561561
/// been called, then no methods except for the ones listed under 4. are allowed to be called
562562
/// on the resulting value of type `T`, either. Multiple such coercion steps are allowed.
563563
/// Regarding 2. and 3., the number of times `__iterator_get_unchecked(idx)` or `next_back()` is
564564
/// called on `self` and the resulting value of type `T` (and on further coercion results with
565-
/// sub-subtypes) are added together and their sums must not exceed the specified bounds.
565+
/// super-supertypes) are added together and their sums must not exceed the specified bounds.
566566
///
567567
/// Further, given that these conditions are met, it must guarantee that:
568568
///
569569
/// * It does not change the value returned from `size_hint`
570570
/// * It must be safe to call the methods listed above on `self` after calling
571571
/// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented.
572572
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
573-
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
573+
/// * If `Self` is a subtype of `T`, then it must be safe to coerce `self` to `T`.
574574
//
575575
// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner`
576576
// after `__iterator_get_unchecked` is supposed to be allowed.
@@ -580,7 +580,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
580580
pub unsafe trait TrustedRandomAccess: TrustedRandomAccessNoCoerce {}
581581

582582
/// Like [`TrustedRandomAccess`] but without any of the requirements / guarantees around
583-
/// coercions to subtypes after `__iterator_get_unchecked` (they aren’t allowed here!), and
583+
/// coercions to supertypes after `__iterator_get_unchecked` (they aren’t allowed here!), and
584584
/// without the requirement that subtypes / supertypes implement `TrustedRandomAccessNoCoerce`.
585585
///
586586
/// This trait was created in PR #85874 to fix soundness issue #85873 without performance regressions.

core/src/num/int_macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ macro_rules! int_impl {
193193
/// Basic usage:
194194
///
195195
/// ```
196-
/// #![feature(integer_sign_cast)]
197196
///
198197
#[doc = concat!("let n = -1", stringify!($SelfT), ";")]
199198
///
200199
#[doc = concat!("assert_eq!(n.cast_unsigned(), ", stringify!($UnsignedT), "::MAX);")]
201200
/// ```
202-
#[unstable(feature = "integer_sign_cast", issue = "125882")]
201+
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
202+
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
203203
#[must_use = "this returns the result of the operation, \
204204
without modifying the original"]
205205
#[inline(always)]

core/src/num/nonzero.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,14 +1633,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
16331633
/// Basic usage:
16341634
///
16351635
/// ```
1636-
/// #![feature(integer_sign_cast)]
16371636
/// # use std::num::NonZero;
16381637
///
16391638
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::MAX;")]
16401639
///
16411640
#[doc = concat!("assert_eq!(n.cast_signed(), NonZero::new(-1", stringify!($Sint), ").unwrap());")]
16421641
/// ```
1643-
#[unstable(feature = "integer_sign_cast", issue = "125882")]
1642+
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
1643+
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
16441644
#[must_use = "this returns the result of the operation, \
16451645
without modifying the original"]
16461646
#[inline(always)]
@@ -2072,14 +2072,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
20722072
/// Basic usage:
20732073
///
20742074
/// ```
2075-
/// #![feature(integer_sign_cast)]
20762075
/// # use std::num::NonZero;
20772076
///
20782077
#[doc = concat!("let n = NonZero::new(-1", stringify!($Int), ").unwrap();")]
20792078
///
20802079
#[doc = concat!("assert_eq!(n.cast_unsigned(), NonZero::<", stringify!($Uint), ">::MAX);")]
20812080
/// ```
2082-
#[unstable(feature = "integer_sign_cast", issue = "125882")]
2081+
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
2082+
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
20832083
#[must_use = "this returns the result of the operation, \
20842084
without modifying the original"]
20852085
#[inline(always)]

core/src/num/uint_macros.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,12 @@ macro_rules! uint_impl {
223223
/// Basic usage:
224224
///
225225
/// ```
226-
/// #![feature(integer_sign_cast)]
227-
///
228226
#[doc = concat!("let n = ", stringify!($SelfT), "::MAX;")]
229227
///
230228
#[doc = concat!("assert_eq!(n.cast_signed(), -1", stringify!($SignedT), ");")]
231229
/// ```
232-
#[unstable(feature = "integer_sign_cast", issue = "125882")]
230+
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
231+
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
233232
#[must_use = "this returns the result of the operation, \
234233
without modifying the original"]
235234
#[inline(always)]

core/src/str/mod.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl str {
198198
/// Basic usage:
199199
///
200200
/// ```
201-
/// use std::str;
201+
/// #![feature(inherent_str_constructors)]
202202
///
203203
/// // some bytes, in a vector
204204
/// let sparkle_heart = vec![240, 159, 146, 150];
@@ -207,13 +207,13 @@ impl str {
207207
/// let sparkle_heart = str::from_utf8(&sparkle_heart)?;
208208
///
209209
/// assert_eq!("💖", sparkle_heart);
210-
/// # Ok::<_, str::Utf8Error>(())
210+
/// # Ok::<_, std::str::Utf8Error>(())
211211
/// ```
212212
///
213213
/// Incorrect bytes:
214214
///
215215
/// ```
216-
/// use std::str;
216+
/// #![feature(inherent_str_constructors)]
217217
///
218218
/// // some invalid bytes, in a vector
219219
/// let sparkle_heart = vec![0, 159, 146, 150];
@@ -227,7 +227,7 @@ impl str {
227227
/// A "stack allocated string":
228228
///
229229
/// ```
230-
/// use std::str;
230+
/// #![feature(inherent_str_constructors)]
231231
///
232232
/// // some bytes, in a stack-allocated array
233233
/// let sparkle_heart = [240, 159, 146, 150];
@@ -238,6 +238,7 @@ impl str {
238238
/// assert_eq!("💖", sparkle_heart);
239239
/// ```
240240
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
241+
#[rustc_diagnostic_item = "str_inherent_from_utf8"]
241242
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
242243
converts::from_utf8(v)
243244
}
@@ -249,7 +250,7 @@ impl str {
249250
/// Basic usage:
250251
///
251252
/// ```
252-
/// use std::str;
253+
/// #![feature(inherent_str_constructors)]
253254
///
254255
/// // "Hello, Rust!" as a mutable vector
255256
/// let mut hellorust = vec![72, 101, 108, 108, 111, 44, 32, 82, 117, 115, 116, 33];
@@ -263,7 +264,7 @@ impl str {
263264
/// Incorrect bytes:
264265
///
265266
/// ```
266-
/// use std::str;
267+
/// #![feature(inherent_str_constructors)]
267268
///
268269
/// // Some invalid bytes in a mutable vector
269270
/// let mut invalid = vec![128, 223];
@@ -274,6 +275,7 @@ impl str {
274275
/// errors that can be returned.
275276
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
276277
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
278+
#[rustc_diagnostic_item = "str_inherent_from_utf8_mut"]
277279
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
278280
converts::from_utf8_mut(v)
279281
}
@@ -292,7 +294,7 @@ impl str {
292294
/// Basic usage:
293295
///
294296
/// ```
295-
/// use std::str;
297+
/// #![feature(inherent_str_constructors)]
296298
///
297299
/// // some bytes, in a vector
298300
/// let sparkle_heart = vec![240, 159, 146, 150];
@@ -306,6 +308,7 @@ impl str {
306308
#[inline]
307309
#[must_use]
308310
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
311+
#[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked"]
309312
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
310313
// SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function.
311314
unsafe { converts::from_utf8_unchecked(v) }
@@ -321,7 +324,7 @@ impl str {
321324
/// Basic usage:
322325
///
323326
/// ```
324-
/// use std::str;
327+
/// #![feature(inherent_str_constructors)]
325328
///
326329
/// let mut heart = vec![240, 159, 146, 150];
327330
/// let heart = unsafe { str::from_utf8_unchecked_mut(&mut heart) };
@@ -331,6 +334,7 @@ impl str {
331334
#[inline]
332335
#[must_use]
333336
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
337+
#[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked_mut"]
334338
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
335339
// SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function.
336340
unsafe { converts::from_utf8_unchecked_mut(v) }

core/src/ub_checks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ macro_rules! assert_unsafe_precondition {
6565
#[rustc_nounwind]
6666
const fn precondition_check($($name:$ty),*) {
6767
if !$e {
68-
::core::panicking::panic_nounwind(
69-
concat!("unsafe precondition(s) violated: ", $message)
70-
);
68+
::core::panicking::panic_nounwind(concat!("unsafe precondition(s) violated: ", $message,
69+
"\n\nThis indicates a bug in the program. \
70+
This Undefined Behavior check is optional, and cannot be relied on for safety."));
7171
}
7272
}
7373

std/src/f16.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,12 +1321,14 @@ impl f16 {
13211321
/// ```
13221322
/// #![feature(f16)]
13231323
/// #![feature(float_erf)]
1324+
/// # #[cfg(reliable_f16_math)] {
13241325
/// let x: f16 = 0.123;
13251326
///
13261327
/// let one = x.erf() + x.erfc();
13271328
/// let abs_difference = (one - 1.0).abs();
13281329
///
13291330
/// assert!(abs_difference <= f16::EPSILON);
1331+
/// # }
13301332
/// ```
13311333
#[rustc_allow_incoherent_impl]
13321334
#[must_use = "method returns a new number and does not mutate the original value"]

0 commit comments

Comments
 (0)