Skip to content

Commit 900e66f

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 9b26bae + 78f5f68 commit 900e66f

File tree

27 files changed

+207
-148
lines changed

27 files changed

+207
-148
lines changed

alloc/src/boxed.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,6 @@ impl<T: ?Sized> Box<T> {
10531053
/// ```
10541054
///
10551055
/// [memory layout]: self#memory-layout
1056-
/// [`Layout`]: crate::Layout
10571056
#[stable(feature = "box_raw", since = "1.4.0")]
10581057
#[inline]
10591058
#[must_use = "call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`"]
@@ -1108,7 +1107,6 @@ impl<T: ?Sized> Box<T> {
11081107
/// ```
11091108
///
11101109
/// [memory layout]: self#memory-layout
1111-
/// [`Layout`]: crate::Layout
11121110
#[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
11131111
#[inline]
11141112
#[must_use = "call `drop(Box::from_non_null(ptr))` if you intend to drop the `Box`"]
@@ -1165,7 +1163,6 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11651163
/// ```
11661164
///
11671165
/// [memory layout]: self#memory-layout
1168-
/// [`Layout`]: crate::Layout
11691166
#[unstable(feature = "allocator_api", issue = "32838")]
11701167
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11711168
#[inline]
@@ -1219,7 +1216,6 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
12191216
/// ```
12201217
///
12211218
/// [memory layout]: self#memory-layout
1222-
/// [`Layout`]: crate::Layout
12231219
#[unstable(feature = "allocator_api", issue = "32838")]
12241220
// #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
12251221
#[rustc_const_unstable(feature = "const_box", issue = "92521")]

core/src/alloc/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use crate::{cmp, ptr};
7070
/// {
7171
/// return null_mut();
7272
/// };
73-
/// self.arena.get().cast::<u8>().add(allocated)
73+
/// unsafe { self.arena.get().cast::<u8>().add(allocated) }
7474
/// }
7575
/// unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
7676
/// }

core/src/error.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ use crate::fmt::{self, Debug, Display, Formatter};
2222
/// accessing that error via [`Error::source()`]. This makes it possible for the
2323
/// high-level module to provide its own errors while also revealing some of the
2424
/// implementation for debugging.
25+
///
26+
/// # Example
27+
///
28+
/// Implementing the `Error` trait only requires that `Debug` and `Display` are implemented too.
29+
///
30+
/// ```
31+
/// use std::error::Error;
32+
/// use std::fmt;
33+
/// use std::path::PathBuf;
34+
///
35+
/// #[derive(Debug)]
36+
/// struct ReadConfigError {
37+
/// path: PathBuf
38+
/// }
39+
///
40+
/// impl fmt::Display for ReadConfigError {
41+
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42+
/// let path = self.path.display();
43+
/// write!(f, "unable to read configuration at {path}")
44+
/// }
45+
/// }
46+
///
47+
/// impl Error for ReadConfigError {}
48+
/// ```
2549
#[stable(feature = "rust1", since = "1.0.0")]
2650
#[cfg_attr(not(test), rustc_diagnostic_item = "Error")]
2751
#[rustc_has_incoherent_inherent_impls]

core/src/hint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use crate::{intrinsics, ub_checks};
5252
/// // Safety: `divisor` can't be zero because of `prepare_inputs`,
5353
/// // but the compiler does not know about this. We *promise*
5454
/// // that we always call `prepare_inputs`.
55-
/// std::hint::unreachable_unchecked()
55+
/// unsafe { std::hint::unreachable_unchecked() }
5656
/// }
5757
/// // The compiler would normally introduce a check here that prevents
5858
/// // a division by zero. However, if `divisor` was zero, the branch

core/src/intrinsics/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,12 +1703,12 @@ pub const fn forget<T: ?Sized>(_: T) {
17031703
/// ```
17041704
/// struct R<'a>(&'a i32);
17051705
/// unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> {
1706-
/// std::mem::transmute::<R<'b>, R<'static>>(r)
1706+
/// unsafe { std::mem::transmute::<R<'b>, R<'static>>(r) }
17071707
/// }
17081708
///
17091709
/// unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>)
17101710
/// -> &'b mut R<'c> {
1711-
/// std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r)
1711+
/// unsafe { std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) }
17121712
/// }
17131713
/// ```
17141714
///
@@ -4498,11 +4498,11 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
44984498
///
44994499
/// // SAFETY: Our precondition ensures the source is aligned and valid,
45004500
/// // and `Vec::with_capacity` ensures that we have usable space to write them.
4501-
/// ptr::copy(ptr, dst.as_mut_ptr(), elts);
4501+
/// unsafe { ptr::copy(ptr, dst.as_mut_ptr(), elts); }
45024502
///
45034503
/// // SAFETY: We created it with this much capacity earlier,
45044504
/// // and the previous `copy` has initialized these elements.
4505-
/// dst.set_len(elts);
4505+
/// unsafe { dst.set_len(elts); }
45064506
/// dst
45074507
/// }
45084508
/// ```

core/src/mem/maybe_uninit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ use crate::{fmt, intrinsics, ptr, slice};
9898
///
9999
/// unsafe fn make_vec(out: *mut Vec<i32>) {
100100
/// // `write` does not drop the old contents, which is important.
101-
/// out.write(vec![1, 2, 3]);
101+
/// unsafe { out.write(vec![1, 2, 3]); }
102102
/// }
103103
///
104104
/// let mut v = MaybeUninit::uninit();
@@ -844,7 +844,7 @@ impl<T> MaybeUninit<T> {
844844
/// # #![allow(unexpected_cfgs)]
845845
/// use std::mem::MaybeUninit;
846846
///
847-
/// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { *buf = [0; 1024] }
847+
/// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { unsafe { *buf = [0; 1024] } }
848848
/// # #[cfg(FALSE)]
849849
/// extern "C" {
850850
/// /// Initializes *all* the bytes of the input buffer.

core/src/mem/transmutability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
3232
/// src: ManuallyDrop::new(src),
3333
/// };
3434
///
35-
/// let dst = transmute.dst;
35+
/// let dst = unsafe { transmute.dst };
3636
///
3737
/// ManuallyDrop::into_inner(dst)
3838
/// }

core/src/ptr/const_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,13 +724,13 @@ impl<T: ?Sized> *const T {
724724
/// that their safety preconditions are met:
725725
/// ```rust
726726
/// # #![feature(ptr_sub_ptr)]
727-
/// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool {
727+
/// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { unsafe {
728728
/// ptr.sub_ptr(origin) == count
729729
/// # &&
730730
/// origin.add(count) == ptr
731731
/// # &&
732732
/// ptr.sub(count) == origin
733-
/// # }
733+
/// # } }
734734
/// ```
735735
///
736736
/// # Safety

core/src/ptr/mut_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,13 +896,13 @@ impl<T: ?Sized> *mut T {
896896
/// that their safety preconditions are met:
897897
/// ```rust
898898
/// # #![feature(ptr_sub_ptr)]
899-
/// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool {
899+
/// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { unsafe {
900900
/// ptr.sub_ptr(origin) == count
901901
/// # &&
902902
/// origin.add(count) == ptr
903903
/// # &&
904904
/// ptr.sub(count) == origin
905-
/// # }
905+
/// # } }
906906
/// ```
907907
///
908908
/// # Safety

core/src/ptr/non_null.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,13 @@ impl<T: ?Sized> NonNull<T> {
857857
/// that their safety preconditions are met:
858858
/// ```rust
859859
/// # #![feature(ptr_sub_ptr)]
860-
/// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool {
860+
/// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool { unsafe {
861861
/// ptr.sub_ptr(origin) == count
862862
/// # &&
863863
/// origin.add(count) == ptr
864864
/// # &&
865865
/// ptr.sub(count) == origin
866-
/// # }
866+
/// # } }
867867
/// ```
868868
///
869869
/// # Safety

0 commit comments

Comments
 (0)