Skip to content

Bounce out the layout refactor from beta #46925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<T> Place<T> for IntermediateBox<T> {
unsafe fn finalize<T>(b: IntermediateBox<T>) -> Box<T> {
let p = b.ptr as *mut T;
mem::forget(b);
Box::from_raw(p)
mem::transmute(p)
}

fn make_place<T>() -> IntermediateBox<T> {
Expand Down Expand Up @@ -300,10 +300,7 @@ impl<T: ?Sized> Box<T> {
issue = "27730")]
#[inline]
pub unsafe fn from_unique(u: Unique<T>) -> Self {
#[cfg(stage0)]
return mem::transmute(u);
#[cfg(not(stage0))]
return Box(u);
mem::transmute(u)
}

/// Consumes the `Box`, returning the wrapped raw pointer.
Expand Down Expand Up @@ -365,14 +362,7 @@ impl<T: ?Sized> Box<T> {
issue = "27730")]
#[inline]
pub fn into_unique(b: Box<T>) -> Unique<T> {
#[cfg(stage0)]
return unsafe { mem::transmute(b) };
#[cfg(not(stage0))]
return {
let unique = b.0;
mem::forget(b);
unique
};
unsafe { mem::transmute(b) }
}
}

Expand Down Expand Up @@ -637,7 +627,7 @@ impl Box<Any + Send> {
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
<Box<Any>>::downcast(self).map_err(|s| unsafe {
// reapply the Send marker
Box::from_raw(Box::into_raw(s) as *mut (Any + Send))
mem::transmute::<Box<Any>, Box<Any + Send>>(s)
})
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![feature(i128)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(match_default_bindings)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(windows, feature(libc))]
#![feature(macro_vis_matcher)]
#![feature(match_default_bindings)]
#![feature(never_type)]
#![feature(nonzero)]
#![feature(quote)]
Expand Down
11 changes: 1 addition & 10 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ use middle::privacy::AccessLevels;
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
use session::{config, early_error, Session};
use traits::Reveal;
use ty::{self, TyCtxt, Ty};
use ty::layout::{LayoutError, LayoutOf, TyLayout};
use ty::{self, TyCtxt};
use util::nodemap::FxHashMap;

use std::default::Default as StdDefault;
Expand Down Expand Up @@ -627,14 +626,6 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
}
}

impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a LateContext<'a, 'tcx> {
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;

fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
(self.tcx, self.param_env.reveal_all()).layout_of(ty)
}
}

impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
/// Because lints are scoped lexically, we want to walk nested
/// items in the context of the outer item, so enable
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'tcx> cmt_<'tcx> {
adt_def.variant_with_id(variant_did)
}
_ => {
assert_eq!(adt_def.variants.len(), 1);
assert!(adt_def.is_univariant());
&adt_def.variants[0]
}
};
Expand Down Expand Up @@ -1096,7 +1096,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
-> cmt<'tcx> {
// univariant enums do not need downcasts
let base_did = self.tcx.parent_def_id(variant_did).unwrap();
if self.tcx.adt_def(base_did).variants.len() != 1 {
if !self.tcx.adt_def(base_did).is_univariant() {
let base_ty = base_cmt.ty;
let ret = Rc::new(cmt_ {
id: node.id(),
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predic
use ty::RegionKind;
use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
use ty::TypeVariants::*;
use ty::layout::{LayoutDetails, TargetDataLayout};
use ty::layout::{Layout, TargetDataLayout};
use ty::maps;
use ty::steal::Steal;
use ty::BindingMode;
Expand Down Expand Up @@ -78,7 +78,7 @@ use hir;
/// Internal storage
pub struct GlobalArenas<'tcx> {
// internings
layout: TypedArena<LayoutDetails>,
layout: TypedArena<Layout>,

// references
generics: TypedArena<ty::Generics>,
Expand Down Expand Up @@ -918,7 +918,7 @@ pub struct GlobalCtxt<'tcx> {

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

layout_interner: RefCell<FxHashSet<&'tcx LayoutDetails>>,
layout_interner: RefCell<FxHashSet<&'tcx Layout>>,

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

pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails {
pub fn intern_layout(self, layout: Layout) -> &'gcx Layout {
if let Some(layout) = self.layout_interner.borrow().get(&layout) {
return layout;
}
Expand Down
Loading