Rollup merge of #49030 - Zoxc:misc, r=michaelwoerister

Misc changes from my parallel rustc branch

r? @michaelwoerister
This commit is contained in:
Alex Crichton 2018-03-23 09:27:19 -05:00
commit 4b31b5bda7
13 changed files with 60 additions and 65 deletions

View file

@ -19,7 +19,7 @@ use graphviz::IntoCow;
use syntax_pos::Span;
use std::borrow::Cow;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
pub type EvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ConstEvalErr<'tcx>>;
@ -52,7 +52,7 @@ impl<'tcx> ConstVal<'tcx> {
#[derive(Clone, Debug)]
pub struct ConstEvalErr<'tcx> {
pub span: Span,
pub kind: Rc<ErrKind<'tcx>>,
pub kind: Lrc<ErrKind<'tcx>>,
}
#[derive(Clone, Debug)]

View file

@ -15,7 +15,7 @@ use std::iter::FromIterator;
use traits::query::CanonicalTyGoal;
use ty::{self, Ty, TyCtxt};
use ty::subst::Kind;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
/// Given a type `ty` of some value being dropped, computes a set
@ -183,13 +183,13 @@ impl_stable_hash_for!(struct DropckOutlivesResult<'tcx> {
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, DropckOutlivesResult<'tcx>> {
// we ought to intern this, but I'm too lazy just now
type Canonicalized = Rc<Canonical<'gcx, QueryResult<'gcx, DropckOutlivesResult<'gcx>>>>;
type Canonicalized = Lrc<Canonical<'gcx, QueryResult<'gcx, DropckOutlivesResult<'gcx>>>>;
fn intern(
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
value: Canonical<'gcx, Self::Lifted>,
) -> Self::Canonicalized {
Rc::new(value)
Lrc::new(value)
}
}

View file

@ -17,7 +17,7 @@ use infer::at::At;
use infer::canonical::{Canonical, Canonicalize, QueryResult};
use middle::const_val::ConstVal;
use mir::interpret::GlobalId;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
use traits::query::CanonicalProjectionGoal;
use traits::project::Normalized;
@ -259,13 +259,13 @@ impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, ty::Pr
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, NormalizationResult<'tcx>> {
// we ought to intern this, but I'm too lazy just now
type Canonicalized = Rc<Canonical<'gcx, QueryResult<'gcx, NormalizationResult<'gcx>>>>;
type Canonicalized = Lrc<Canonical<'gcx, QueryResult<'gcx, NormalizationResult<'gcx>>>>;
fn intern(
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
value: Canonical<'gcx, Self::Lifted>,
) -> Self::Canonicalized {
Rc::new(value)
Lrc::new(value)
}
}

View file

@ -161,12 +161,12 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
-> Ty<'tcx> {
let ty = {
let mut interner = self.type_.borrow_mut();
let global_interner = global_interners.map(|interners| {
interners.type_.borrow_mut()
});
if let Some(&Interned(ty)) = interner.get(&st) {
return ty;
}
let global_interner = global_interners.map(|interners| {
interners.type_.borrow_mut()
});
if let Some(ref interner) = global_interner {
if let Some(&Interned(ty)) = interner.get(&st) {
return ty;
@ -1010,17 +1010,16 @@ impl<'tcx> InterpretInterner<'tcx> {
}
}
impl<'tcx> GlobalCtxt<'tcx> {
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Get the global TyCtxt.
pub fn global_tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
#[inline]
pub fn global_tcx(self) -> TyCtxt<'a, 'gcx, 'gcx> {
TyCtxt {
gcx: self,
interners: &self.global_interners
gcx: self.gcx,
interners: &self.gcx.global_interners,
}
}
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
self.global_arenas.generics.alloc(generics)
}
@ -1081,12 +1080,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self,
alloc: interpret::Allocation,
) -> &'gcx interpret::Allocation {
if let Some(alloc) = self.interpret_interner.inner.borrow().allocs.get(&alloc) {
let allocs = &mut self.interpret_interner.inner.borrow_mut().allocs;
if let Some(alloc) = allocs.get(&alloc) {
return alloc;
}
let interned = self.global_arenas.const_allocs.alloc(alloc);
if let Some(prev) = self.interpret_interner.inner.borrow_mut().allocs.replace(interned) {
if let Some(prev) = allocs.replace(interned) {
bug!("Tried to overwrite interned Allocation: {:#?}", prev)
}
interned
@ -1113,24 +1113,26 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
pub fn intern_stability(self, stab: attr::Stability) -> &'gcx attr::Stability {
if let Some(st) = self.stability_interner.borrow().get(&stab) {
let mut stability_interner = self.stability_interner.borrow_mut();
if let Some(st) = stability_interner.get(&stab) {
return st;
}
let interned = self.global_interners.arena.alloc(stab);
if let Some(prev) = self.stability_interner.borrow_mut().replace(interned) {
if let Some(prev) = stability_interner.replace(interned) {
bug!("Tried to overwrite interned Stability: {:?}", prev)
}
interned
}
pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails {
if let Some(layout) = self.layout_interner.borrow().get(&layout) {
let mut layout_interner = self.layout_interner.borrow_mut();
if let Some(layout) = layout_interner.get(&layout) {
return layout;
}
let interned = self.global_arenas.layout.alloc(layout);
if let Some(prev) = self.layout_interner.borrow_mut().replace(interned) {
if let Some(prev) = layout_interner.replace(interned) {
bug!("Tried to overwrite interned Layout: {:?}", prev)
}
interned

View file

@ -18,6 +18,7 @@ use ty::{self, Lift, Ty, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use rustc_data_structures::accumulate_vec::AccumulateVec;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use rustc_data_structures::sync::Lrc;
use mir::interpret;
use std::rc::Rc;
@ -465,7 +466,7 @@ impl<'a, 'tcx> Lift<'tcx> for ConstEvalErr<'a> {
tcx.lift(&*self.kind).map(|kind| {
ConstEvalErr {
span: self.span,
kind: Rc::new(kind),
kind: Lrc::new(kind),
}
})
}