Skip to content

Commit b76ee83

Browse files
committed
Auto merge of #55859 - pietroalbini:rollup, r=kennytm
Rollup of 17 pull requests Successful merges: - #55630 (resolve: Filter away macro prelude in modules with `#[no_implicit_prelude]` on 2018 edition) - #55687 (Take supertraits into account when calculating associated types) - #55745 (Convert `outlives_components`' return value to a `SmallVec` outparam.) - #55764 (Fix Rc/Arc allocation layout) - #55792 (Prevent ICE in const-prop array oob check) - #55799 (Removed unneeded instance of `// revisions` from a lint test) - #55800 (Fix ICE in `return_type_impl_trait`) - #55801 (NLL: Update box insensitivity test) - #55802 (Don't inline virtual calls (take 2)) - #55816 (Use `SmallVec` to avoid allocations in `from_decimal_string`.) - #55819 (Typecheck patterns of all match arms first, so we get types for bindings) - #55822 (ICE with #![feature(nll)] and elided lifetimes) - #55828 (Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`) - #55839 (Fix docstring spelling mistakes) - #55844 (Fix documentation typos.) - #55845 (Set BINARYEN_TRAP_MODE=clamp) - #55856 (rustdoc: refactor: move all static-file include!s into a single module)
2 parents 9b8f902 + 7031e4e commit b76ee83

File tree

85 files changed

+1117
-666
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1117
-666
lines changed

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,7 @@ version = "0.0.0"
20962096
dependencies = [
20972097
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
20982098
"rustc_cratesio_shim 0.0.0",
2099+
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
20992100
]
21002101

21012102
[[package]]

src/liballoc/rc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,16 @@ impl<T: ?Sized> Rc<T> {
672672
// Previously, layout was calculated on the expression
673673
// `&*(ptr as *const RcBox<T>)`, but this created a misaligned
674674
// reference (see #54908).
675-
let (layout, _) = Layout::new::<RcBox<()>>()
676-
.extend(Layout::for_value(&*ptr)).unwrap();
675+
let layout = Layout::new::<RcBox<()>>()
676+
.extend(Layout::for_value(&*ptr)).unwrap().0
677+
.pad_to_align().unwrap();
677678

678679
let mem = Global.alloc(layout)
679680
.unwrap_or_else(|_| handle_alloc_error(layout));
680681

681682
// Initialize the RcBox
682683
let inner = set_data_ptr(ptr as *mut T, mem.as_ptr() as *mut u8) as *mut RcBox<T>;
684+
debug_assert_eq!(Layout::for_value(&*inner), layout);
683685

684686
ptr::write(&mut (*inner).strong, Cell::new(1));
685687
ptr::write(&mut (*inner).weak, Cell::new(1));

src/liballoc/sync.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,16 @@ impl<T: ?Sized> Arc<T> {
575575
// Previously, layout was calculated on the expression
576576
// `&*(ptr as *const ArcInner<T>)`, but this created a misaligned
577577
// reference (see #54908).
578-
let (layout, _) = Layout::new::<ArcInner<()>>()
579-
.extend(Layout::for_value(&*ptr)).unwrap();
578+
let layout = Layout::new::<ArcInner<()>>()
579+
.extend(Layout::for_value(&*ptr)).unwrap().0
580+
.pad_to_align().unwrap();
580581

581582
let mem = Global.alloc(layout)
582583
.unwrap_or_else(|_| handle_alloc_error(layout));
583584

584585
// Initialize the ArcInner
585586
let inner = set_data_ptr(ptr as *mut T, mem.as_ptr() as *mut u8) as *mut ArcInner<T>;
587+
debug_assert_eq!(Layout::for_value(&*inner), layout);
586588

587589
ptr::write(&mut (*inner).strong, atomic::AtomicUsize::new(1));
588590
ptr::write(&mut (*inner).weak, atomic::AtomicUsize::new(1));

src/libcore/alloc.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ impl Layout {
218218
len_rounded_up.wrapping_sub(len)
219219
}
220220

221+
/// Creates a layout by rounding the size of this layout up to a multiple
222+
/// of the layout's alignment.
223+
///
224+
/// Returns `Err` if the padded size would overflow.
225+
///
226+
/// This is equivalent to adding the result of `padding_needed_for`
227+
/// to the layout's current size.
228+
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
229+
#[inline]
230+
pub fn pad_to_align(&self) -> Result<Layout, LayoutErr> {
231+
let pad = self.padding_needed_for(self.align());
232+
let new_size = self.size().checked_add(pad)
233+
.ok_or(LayoutErr { private: () })?;
234+
235+
Layout::from_size_align(new_size, self.align())
236+
}
237+
221238
/// Creates a layout describing the record for `n` instances of
222239
/// `self`, with a suitable amount of padding between each to
223240
/// ensure that each instance is given its requested size and
@@ -506,7 +523,7 @@ pub unsafe trait GlobalAlloc {
506523
ptr
507524
}
508525

509-
/// Shink or grow a block of memory to the given `new_size`.
526+
/// Shrink or grow a block of memory to the given `new_size`.
510527
/// The block is described by the given `ptr` pointer and `layout`.
511528
///
512529
/// If this returns a non-null pointer, then ownership of the memory block
@@ -757,7 +774,7 @@ pub unsafe trait Alloc {
757774
// realloc. alloc_excess, realloc_excess
758775

759776
/// Returns a pointer suitable for holding data described by
760-
/// a new layout with `layout`’s alginment and a size given
777+
/// a new layout with `layout`’s alignment and a size given
761778
/// by `new_size`. To
762779
/// accomplish this, this may extend or shrink the allocation
763780
/// referenced by `ptr` to fit the new layout.

src/libcore/future/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ops;
1717
use pin::Pin;
1818
use task::{Poll, LocalWaker};
1919

20-
/// A future represents an asychronous computation.
20+
/// A future represents an asynchronous computation.
2121
///
2222
/// A future is a value that may not have finished computing yet. This kind of
2323
/// "asynchronous value" makes it possible for a thread to continue doing useful

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ mod nonzero;
228228
mod tuple;
229229
mod unit;
230230

231-
// Pull in the the `coresimd` crate directly into libcore. This is where all the
231+
// Pull in the `coresimd` crate directly into libcore. This is where all the
232232
// architecture-specific (and vendor-specific) intrinsics are defined. AKA
233233
// things like SIMD and such. Note that the actual source for all this lies in a
234234
// different repository, rust-lang-nursery/stdsimd. That's why the setup here is

src/libcore/macros.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,8 @@ macro_rules! try {
350350
/// assert_eq!(v, b"s = \"abc 123\"");
351351
/// ```
352352
///
353-
/// Note: This macro can be used in `no_std` setups as well
354-
/// In a `no_std` setup you are responsible for the
355-
/// implementation details of the components.
353+
/// Note: This macro can be used in `no_std` setups as well.
354+
/// In a `no_std` setup you are responsible for the implementation details of the components.
356355
///
357356
/// ```no_run
358357
/// # extern crate core;
@@ -440,7 +439,7 @@ macro_rules! writeln {
440439
///
441440
/// If the determination that the code is unreachable proves incorrect, the
442441
/// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`],
443-
/// which belongs to the [`std::hint`] module, informs the compilier to
442+
/// which belongs to the [`std::hint`] module, informs the compiler to
444443
/// optimize the code out of the release version entirely.
445444
///
446445
/// [`panic!`]: ../std/macro.panic.html

src/libcore/mem.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub fn forget<T>(t: T) {
202202
///
203203
/// ## Size of Enums
204204
///
205-
/// Enums that carry no data other than the descriminant have the same size as C enums
205+
/// Enums that carry no data other than the discriminant have the same size as C enums
206206
/// on the platform they are compiled for.
207207
///
208208
/// ## Size of Unions
@@ -1081,7 +1081,7 @@ impl<T> MaybeUninit<T> {
10811081
///
10821082
/// # Unsafety
10831083
///
1084-
/// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
1084+
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
10851085
/// state, otherwise this will immediately cause undefined behavior.
10861086
#[unstable(feature = "maybe_uninit", issue = "53491")]
10871087
pub unsafe fn into_inner(self) -> T {
@@ -1092,7 +1092,7 @@ impl<T> MaybeUninit<T> {
10921092
///
10931093
/// # Unsafety
10941094
///
1095-
/// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
1095+
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
10961096
/// state, otherwise this will immediately cause undefined behavior.
10971097
#[unstable(feature = "maybe_uninit", issue = "53491")]
10981098
pub unsafe fn get_ref(&self) -> &T {
@@ -1103,7 +1103,7 @@ impl<T> MaybeUninit<T> {
11031103
///
11041104
/// # Unsafety
11051105
///
1106-
/// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
1106+
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
11071107
/// state, otherwise this will immediately cause undefined behavior.
11081108
#[unstable(feature = "maybe_uninit", issue = "53491")]
11091109
pub unsafe fn get_mut(&mut self) -> &mut T {

src/libcore/num/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@ Basic usage:
21522152
", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), 0);", $EndFeature, "
21532153
```"),
21542154
#[stable(feature = "rust1", since = "1.0.0")]
2155+
#[rustc_promotable]
21552156
#[inline]
21562157
pub const fn min_value() -> Self { 0 }
21572158
}
@@ -2168,6 +2169,7 @@ Basic usage:
21682169
stringify!($MaxV), ");", $EndFeature, "
21692170
```"),
21702171
#[stable(feature = "rust1", since = "1.0.0")]
2172+
#[rustc_promotable]
21712173
#[inline]
21722174
pub const fn max_value() -> Self { !0 }
21732175
}

src/libcore/pin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! It is sometimes useful to have objects that are guaranteed to not move,
44
//! in the sense that their placement in memory does not change, and can thus be relied upon.
55
//!
6-
//! A prime example of such a scenario would be building self-referencial structs,
6+
//! A prime example of such a scenario would be building self-referential structs,
77
//! since moving an object with pointers to itself will invalidate them,
88
//! which could cause undefined behavior.
99
//!
@@ -39,7 +39,7 @@
3939
//! use std::marker::Pinned;
4040
//! use std::ptr::NonNull;
4141
//!
42-
//! // This is a self referencial struct since the slice field points to the data field.
42+
//! // This is a self-referential struct since the slice field points to the data field.
4343
//! // We cannot inform the compiler about that with a normal reference,
4444
//! // since this pattern cannot be described with the usual borrowing rules.
4545
//! // Instead we use a raw pointer, though one which is known to not be null,

0 commit comments

Comments
 (0)