Skip to content

Commit 4979bcc

Browse files
committed
Auto merge of #46925 - arielb1:make-the-trains-run-on-time, r=arielb1
Bounce out the layout refactor from beta @eddyb's #45225 was supposed to get into get into 1.24, but due to an ordering mistake, it had snuck into 1.23. That wide-effect translation-changing PR had poked LLVM's weak corners and caused many regressions (3 of them have fixes I include here, but also #46897, #46845, #46449, #46371). I don't think it is a good idea to land it in the beta (1.23) because there are bound to be some regressions we didn't patch. Therefore, I am reverting it in time for stable, along with its related regression fixes. r? @michaelwoerister (I think)
2 parents 3ab24df + d6a5946 commit 4979bcc

Some content is hidden

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

93 files changed

+5614
-4977
lines changed

src/liballoc/boxed.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<T> Place<T> for IntermediateBox<T> {
151151
unsafe fn finalize<T>(b: IntermediateBox<T>) -> Box<T> {
152152
let p = b.ptr as *mut T;
153153
mem::forget(b);
154-
Box::from_raw(p)
154+
mem::transmute(p)
155155
}
156156

157157
fn make_place<T>() -> IntermediateBox<T> {
@@ -300,10 +300,7 @@ impl<T: ?Sized> Box<T> {
300300
issue = "27730")]
301301
#[inline]
302302
pub unsafe fn from_unique(u: Unique<T>) -> Self {
303-
#[cfg(stage0)]
304-
return mem::transmute(u);
305-
#[cfg(not(stage0))]
306-
return Box(u);
303+
mem::transmute(u)
307304
}
308305

309306
/// Consumes the `Box`, returning the wrapped raw pointer.
@@ -365,14 +362,7 @@ impl<T: ?Sized> Box<T> {
365362
issue = "27730")]
366363
#[inline]
367364
pub fn into_unique(b: Box<T>) -> Unique<T> {
368-
#[cfg(stage0)]
369-
return unsafe { mem::transmute(b) };
370-
#[cfg(not(stage0))]
371-
return {
372-
let unique = b.0;
373-
mem::forget(b);
374-
unique
375-
};
365+
unsafe { mem::transmute(b) }
376366
}
377367
}
378368

@@ -637,7 +627,7 @@ impl Box<Any + Send> {
637627
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
638628
<Box<Any>>::downcast(self).map_err(|s| unsafe {
639629
// reapply the Send marker
640-
Box::from_raw(Box::into_raw(s) as *mut (Any + Send))
630+
mem::transmute::<Box<Any>, Box<Any + Send>>(s)
641631
})
642632
}
643633
}

src/librustc/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@
4646
#![feature(const_fn)]
4747
#![feature(core_intrinsics)]
4848
#![feature(drain_filter)]
49-
#![feature(i128)]
5049
#![feature(i128_type)]
51-
#![feature(inclusive_range)]
50+
#![feature(match_default_bindings)]
5251
#![feature(inclusive_range_syntax)]
5352
#![cfg_attr(windows, feature(libc))]
5453
#![feature(macro_vis_matcher)]
55-
#![feature(match_default_bindings)]
5654
#![feature(never_type)]
5755
#![feature(nonzero)]
5856
#![feature(quote)]

src/librustc/lint/context.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use middle::privacy::AccessLevels;
3434
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
3535
use session::{config, early_error, Session};
3636
use traits::Reveal;
37-
use ty::{self, TyCtxt, Ty};
38-
use ty::layout::{LayoutError, LayoutOf, TyLayout};
37+
use ty::{self, TyCtxt};
3938
use util::nodemap::FxHashMap;
4039

4140
use std::default::Default as StdDefault;
@@ -627,14 +626,6 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
627626
}
628627
}
629628

630-
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a LateContext<'a, 'tcx> {
631-
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
632-
633-
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
634-
(self.tcx, self.param_env.reveal_all()).layout_of(ty)
635-
}
636-
}
637-
638629
impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
639630
/// Because lints are scoped lexically, we want to walk nested
640631
/// items in the context of the outer item, so enable

src/librustc/middle/mem_categorization.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'tcx> cmt_<'tcx> {
210210
adt_def.variant_with_id(variant_did)
211211
}
212212
_ => {
213-
assert_eq!(adt_def.variants.len(), 1);
213+
assert!(adt_def.is_univariant());
214214
&adt_def.variants[0]
215215
}
216216
};
@@ -1096,7 +1096,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
10961096
-> cmt<'tcx> {
10971097
// univariant enums do not need downcasts
10981098
let base_did = self.tcx.parent_def_id(variant_did).unwrap();
1099-
if self.tcx.adt_def(base_did).variants.len() != 1 {
1099+
if !self.tcx.adt_def(base_did).is_univariant() {
11001100
let base_ty = base_cmt.ty;
11011101
let ret = Rc::new(cmt_ {
11021102
id: node.id(),

src/librustc/ty/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predic
4141
use ty::RegionKind;
4242
use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
4343
use ty::TypeVariants::*;
44-
use ty::layout::{LayoutDetails, TargetDataLayout};
44+
use ty::layout::{Layout, TargetDataLayout};
4545
use ty::maps;
4646
use ty::steal::Steal;
4747
use ty::BindingMode;
@@ -78,7 +78,7 @@ use hir;
7878
/// Internal storage
7979
pub struct GlobalArenas<'tcx> {
8080
// internings
81-
layout: TypedArena<LayoutDetails>,
81+
layout: TypedArena<Layout>,
8282

8383
// references
8484
generics: TypedArena<ty::Generics>,
@@ -918,7 +918,7 @@ pub struct GlobalCtxt<'tcx> {
918918

919919
stability_interner: RefCell<FxHashSet<&'tcx attr::Stability>>,
920920

921-
layout_interner: RefCell<FxHashSet<&'tcx LayoutDetails>>,
921+
layout_interner: RefCell<FxHashSet<&'tcx Layout>>,
922922

923923
/// A vector of every trait accessible in the whole crate
924924
/// (i.e. including those from subcrates). This is used only for
@@ -1016,7 +1016,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10161016
interned
10171017
}
10181018

1019-
pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails {
1019+
pub fn intern_layout(self, layout: Layout) -> &'gcx Layout {
10201020
if let Some(layout) = self.layout_interner.borrow().get(&layout) {
10211021
return layout;
10221022
}

0 commit comments

Comments
 (0)