diff options
| author | bors <bors@rust-lang.org> | 2018-11-11 06:26:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-11-11 06:26:21 +0000 |
| commit | b76ee83254ec0398da554f25c2168d917ba60f1c (patch) | |
| tree | b2d4ff143f4ceda8c5de52252d5f273aa66e2207 /src/liballoc | |
| parent | 9b8f9029762da90a88c8ca6f8ff7690177ec696a (diff) | |
| parent | 7031e4e7c7b2ab5041aaf9ac54b3bd92169ab908 (diff) | |
| download | rust-b76ee83254ec0398da554f25c2168d917ba60f1c.tar.gz rust-b76ee83254ec0398da554f25c2168d917ba60f1c.zip | |
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)
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/rc.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 45f035ad04f..bb52d7990ff 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -672,14 +672,16 @@ impl<T: ?Sized> Rc<T> { // Previously, layout was calculated on the expression // `&*(ptr as *const RcBox<T>)`, but this created a misaligned // reference (see #54908). - let (layout, _) = Layout::new::<RcBox<()>>() - .extend(Layout::for_value(&*ptr)).unwrap(); + let layout = Layout::new::<RcBox<()>>() + .extend(Layout::for_value(&*ptr)).unwrap().0 + .pad_to_align().unwrap(); let mem = Global.alloc(layout) .unwrap_or_else(|_| handle_alloc_error(layout)); // Initialize the RcBox let inner = set_data_ptr(ptr as *mut T, mem.as_ptr() as *mut u8) as *mut RcBox<T>; + debug_assert_eq!(Layout::for_value(&*inner), layout); ptr::write(&mut (*inner).strong, Cell::new(1)); ptr::write(&mut (*inner).weak, Cell::new(1)); diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2c396b3b06b..b63b3684964 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -575,14 +575,16 @@ impl<T: ?Sized> Arc<T> { // Previously, layout was calculated on the expression // `&*(ptr as *const ArcInner<T>)`, but this created a misaligned // reference (see #54908). - let (layout, _) = Layout::new::<ArcInner<()>>() - .extend(Layout::for_value(&*ptr)).unwrap(); + let layout = Layout::new::<ArcInner<()>>() + .extend(Layout::for_value(&*ptr)).unwrap().0 + .pad_to_align().unwrap(); let mem = Global.alloc(layout) .unwrap_or_else(|_| handle_alloc_error(layout)); // Initialize the ArcInner let inner = set_data_ptr(ptr as *mut T, mem.as_ptr() as *mut u8) as *mut ArcInner<T>; + debug_assert_eq!(Layout::for_value(&*inner), layout); ptr::write(&mut (*inner).strong, atomic::AtomicUsize::new(1)); ptr::write(&mut (*inner).weak, atomic::AtomicUsize::new(1)); |
