Skip to content
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

Rollup of 8 pull requests #61418

Merged
merged 17 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
#![feature(const_str_len)]
#![feature(const_int_conversion)]
#![feature(const_transmute)]
#![feature(reverse_bits)]
#![feature(non_exhaustive)]
#![feature(structural_match)]
#![feature(abi_unadjusted)]
Expand Down
9 changes: 2 additions & 7 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,12 @@ assert_eq!(m, ", $swapped, ");
Basic usage:

```
#![feature(reverse_bits)]

let n = ", $swap_op, stringify!($SelfT), ";
let m = n.reverse_bits();

assert_eq!(m, ", $reversed, ");
```"),
#[unstable(feature = "reverse_bits", issue = "48763")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[stable(feature = "reverse_bits", since = "1.37.0")]
#[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self {
Expand Down Expand Up @@ -2514,14 +2511,12 @@ assert_eq!(m, ", $swapped, ");
Basic usage:

```
#![feature(reverse_bits)]

let n = ", $swap_op, stringify!($SelfT), ";
let m = n.reverse_bits();

assert_eq!(m, ", $reversed, ");
```"),
#[unstable(feature = "reverse_bits", issue = "48763")]
#[stable(feature = "reverse_bits", since = "1.37.0")]
#[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self {
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ assert_eq!(n.trailing_zeros(), 3);
/// Basic usage:
///
/// ```
/// #![feature(reverse_bits)]
/// use std::num::Wrapping;
///
/// let n = Wrapping(0b0000000_01010101i16);
Expand All @@ -522,7 +521,7 @@ assert_eq!(n.trailing_zeros(), 3);
/// assert_eq!(m.0 as u16, 0b10101010_00000000);
/// assert_eq!(m, Wrapping(-22016));
/// ```
#[unstable(feature = "reverse_bits", issue = "48763")]
#[stable(feature = "reverse_bits", since = "1.37.0")]
#[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self {
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#![feature(test)]
#![feature(trusted_len)]
#![feature(try_trait)]
#![feature(reverse_bits)]
#![feature(inner_deref)]
#![feature(slice_internals)]
#![feature(slice_partition_dedup)]
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ use smallvec::SmallVec;
macro_rules! arena_types {
($macro:path, $args:tt, $tcx:lifetime) => (
$macro!($args, [
[] layouts: rustc::ty::layout::LayoutDetails,
[] generics: rustc::ty::Generics,
[] trait_def: rustc::ty::TraitDef,
[] adt_def: rustc::ty::AdtDef,
[] steal_mir: rustc::ty::steal::Steal<rustc::mir::Body<$tcx>>,
[] mir: rustc::mir::Body<$tcx>,
[] tables: rustc::ty::TypeckTables<$tcx>,
[] const_allocs: rustc::mir::interpret::Allocation,
[] vtable_method: Option<(
rustc::hir::def_id::DefId,
rustc::ty::subst::SubstsRef<$tcx>
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ for ty::RegionKind {
ty::ReClosureBound(vid) => {
vid.hash_stable(hcx, hasher);
}
ty::ReLateBound(..) |
ty::ReVar(..) |
ty::RePlaceholder(..) => {
bug!("StableHasher: unexpected region {:?}", *self)
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
format!("the anonymous lifetime #{} defined on", idx + 1),
self.hir().span_by_hir_id(node),
),
ty::BrFresh(_) => (
"an anonymous lifetime defined on".to_owned(),
self.hir().span_by_hir_id(node),
),
_ => (
format!("the lifetime {} as defined on", region),
cm.def_span(self.hir().span_by_hir_id(node)),
Expand Down
42 changes: 2 additions & 40 deletions src/librustc/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::unify as ut;
use crate::ty::ReStatic;
use crate::ty::{self, Ty, TyCtxt};
use crate::ty::{BrFresh, ReLateBound, ReVar};
use crate::ty::{ReLateBound, ReVar};
use crate::ty::{Region, RegionVid};

use std::collections::BTreeMap;
use std::{cmp, fmt, mem, u32};
use std::{cmp, fmt, mem};
use std::ops::Range;

mod leak_check;
Expand All @@ -37,10 +37,6 @@ pub struct RegionConstraintCollector<'tcx> {
/// exist). This prevents us from making many such regions.
glbs: CombineMap<'tcx>,

/// Global counter used during the GLB algorithm to create unique
/// names for fresh bound regions
bound_count: u32,

/// The undo log records actions that might later be undone.
///
/// Note: `num_open_snapshots` is used to track if we are actively
Expand Down Expand Up @@ -392,7 +388,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
data,
lubs,
glbs,
bound_count: _,
undo_log: _,
num_open_snapshots: _,
unification_table,
Expand Down Expand Up @@ -579,39 +574,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
}
}

pub fn new_bound(
&mut self,
tcx: TyCtxt<'_, '_, 'tcx>,
debruijn: ty::DebruijnIndex,
) -> Region<'tcx> {
// Creates a fresh bound variable for use in GLB computations.
// See discussion of GLB computation in the large comment at
// the top of this file for more details.
//
// This computation is potentially wrong in the face of
// rollover. It's conceivable, if unlikely, that one might
// wind up with accidental capture for nested functions in
// that case, if the outer function had bound regions created
// a very long time before and the inner function somehow
// wound up rolling over such that supposedly fresh
// identifiers were in fact shadowed. For now, we just assert
// that there is no rollover -- eventually we should try to be
// robust against this possibility, either by checking the set
// of bound identifiers that appear in a given expression and
// ensure that we generate one that is distinct, or by
// changing the representation of bound regions in a fn
// declaration

let sc = self.bound_count;
self.bound_count = sc + 1;

if sc >= self.bound_count {
bug!("rollover in RegionInference new_bound()");
}

tcx.mk_region(ReLateBound(debruijn, BrFresh(sc)))
}

fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
// cannot add constraints once regions are resolved
debug!(
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rustc_queries! {
load_cached(tcx, id) {
let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
.try_load_query_result(tcx, id);
generics.map(|x| tcx.alloc_generics(x))
generics.map(|x| &*tcx.arena.alloc(x))
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ rustc_queries! {
load_cached(tcx, id) {
let mir: Option<crate::mir::Body<'tcx>> = tcx.queries.on_disk_cache
.try_load_query_result(tcx, id);
mir.map(|x| tcx.alloc_mir(x))
mir.map(|x| &*tcx.arena.alloc(x))
}
}
}
Expand Down Expand Up @@ -353,7 +353,7 @@ rustc_queries! {
.queries.on_disk_cache
.try_load_query_result(tcx, id);

typeck_tables.map(|tables| tcx.alloc_tables(tables))
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
}
}
}
Expand Down
56 changes: 10 additions & 46 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use smallvec::SmallVec;
use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
StableHasher, StableHasherResult,
StableVec};
use arena::{TypedArena, SyncDroplessArena};
use arena::SyncDroplessArena;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_data_structures::sync::{Lrc, Lock, WorkerLocal};
use std::any::Any;
Expand All @@ -79,37 +79,18 @@ use syntax_pos::Span;

use crate::hir;

pub struct AllArenas<'tcx> {
pub global: WorkerLocal<GlobalArenas<'tcx>>,
pub struct AllArenas {
pub interner: SyncDroplessArena,
}

impl<'tcx> AllArenas<'tcx> {
impl AllArenas {
pub fn new() -> Self {
AllArenas {
global: WorkerLocal::new(|_| GlobalArenas::default()),
interner: SyncDroplessArena::default(),
}
}
}

/// Internal storage
#[derive(Default)]
pub struct GlobalArenas<'tcx> {
// internings
layout: TypedArena<LayoutDetails>,

// references
generics: TypedArena<ty::Generics>,
trait_def: TypedArena<ty::TraitDef>,
adt_def: TypedArena<ty::AdtDef>,
steal_mir: TypedArena<Steal<Body<'tcx>>>,
mir: TypedArena<Body<'tcx>>,
tables: TypedArena<ty::TypeckTables<'tcx>>,
/// miri allocations
const_allocs: TypedArena<interpret::Allocation>,
}

type InternedSet<'tcx, T> = Lock<FxHashMap<Interned<'tcx, T>, ()>>;

pub struct CtxtInterners<'tcx> {
Expand Down Expand Up @@ -1043,7 +1024,7 @@ impl<'gcx> Deref for TyCtxt<'_, 'gcx, '_> {

pub struct GlobalCtxt<'tcx> {
pub arena: WorkerLocal<Arena<'tcx>>,
global_arenas: &'tcx WorkerLocal<GlobalArenas<'tcx>>,

global_interners: CtxtInterners<'tcx>,

cstore: &'tcx CrateStoreDyn,
Expand Down Expand Up @@ -1150,24 +1131,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
&self.hir_map
}

pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
self.global_arenas.generics.alloc(generics)
}

pub fn alloc_steal_mir(self, mir: Body<'gcx>) -> &'gcx Steal<Body<'gcx>> {
self.global_arenas.steal_mir.alloc(Steal::new(mir))
}

pub fn alloc_mir(self, mir: Body<'gcx>) -> &'gcx Body<'gcx> {
self.global_arenas.mir.alloc(mir)
}

pub fn alloc_tables(self, tables: ty::TypeckTables<'gcx>) -> &'gcx ty::TypeckTables<'gcx> {
self.global_arenas.tables.alloc(tables)
}

pub fn alloc_trait_def(self, def: ty::TraitDef) -> &'gcx ty::TraitDef {
self.global_arenas.trait_def.alloc(def)
self.arena.alloc(Steal::new(mir))
}

pub fn alloc_adt_def(self,
Expand All @@ -1177,12 +1142,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
repr: ReprOptions)
-> &'gcx ty::AdtDef {
let def = ty::AdtDef::new(self, did, kind, variants, repr);
self.global_arenas.adt_def.alloc(def)
self.arena.alloc(def)
}

pub fn intern_const_alloc(self, alloc: Allocation) -> &'gcx Allocation {
self.allocation_interner.borrow_mut().intern(alloc, |alloc| {
self.global_arenas.const_allocs.alloc(alloc)
self.arena.alloc(alloc)
})
}

Expand All @@ -1196,13 +1161,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

pub fn intern_stability(self, stab: attr::Stability) -> &'gcx attr::Stability {
self.stability_interner.borrow_mut().intern(stab, |stab| {
self.global_interners.arena.alloc(stab)
self.arena.alloc(stab)
})
}

pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails {
self.layout_interner.borrow_mut().intern(layout, |layout| {
self.global_arenas.layout.alloc(layout)
self.arena.alloc(layout)
})
}

Expand Down Expand Up @@ -1250,7 +1215,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
cstore: &'tcx CrateStoreDyn,
local_providers: ty::query::Providers<'tcx>,
extern_providers: ty::query::Providers<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
arenas: &'tcx AllArenas,
resolutions: ty::Resolutions,
hir: hir_map::Map<'tcx>,
on_disk_query_result_cache: query::OnDiskCache<'tcx>,
Expand Down Expand Up @@ -1319,7 +1284,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
sess: s,
cstore,
arena: WorkerLocal::new(|_| Arena::default()),
global_arenas: &arenas.global,
global_interners: interners,
dep_graph,
common,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub use self::sty::TyKind::*;
pub use self::binding::BindingMode;
pub use self::binding::BindingMode::*;

pub use self::context::{TyCtxt, FreeRegionInfo, GlobalArenas, AllArenas, tls, keep_local};
pub use self::context::{TyCtxt, FreeRegionInfo, AllArenas, tls, keep_local};
pub use self::context::{Lift, TypeckTables, CtxtInterners, GlobalCtxt};
pub use self::context::{
UserTypeAnnotationIndex, UserType, CanonicalUserType,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,6 @@ impl<F: fmt::Write> FmtPrinter<'_, 'gcx, 'tcx, F> {
br
}
ty::BrAnon(_) |
ty::BrFresh(_) |
ty::BrEnv => {
let name = loop {
let name = name_by_region_index(region_index);
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ impl fmt::Debug for ty::BoundRegion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
ty::BrFresh(n) => write!(f, "BrFresh({:?})", n),
ty::BrNamed(did, name) => {
write!(f, "BrNamed({:?}:{:?}, {})",
did.krate, did.index, name)
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ pub enum BoundRegion {
/// the event of shadowing.
BrNamed(DefId, InternedString),

/// Fresh bound identifiers created during GLB computations.
BrFresh(u32),

/// Anonymous region for the implicit env pointer parameter
/// to a closure
BrEnv,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ impl IntoArgs for (CrateNum, DefId) {
provide! { <'tcx> tcx, def_id, other, cdata,
type_of => { cdata.get_type(def_id.index, tcx) }
generics_of => {
tcx.alloc_generics(cdata.get_generics(def_id.index, tcx.sess))
tcx.arena.alloc(cdata.get_generics(def_id.index, tcx.sess))
}
predicates_of => { tcx.arena.alloc(cdata.get_predicates(def_id.index, tcx)) }
predicates_defined_on => {
tcx.arena.alloc(cdata.get_predicates_defined_on(def_id.index, tcx))
}
super_predicates_of => { tcx.arena.alloc(cdata.get_super_predicates(def_id.index, tcx)) }
trait_def => {
tcx.alloc_trait_def(cdata.get_trait_def(def_id.index, tcx.sess))
tcx.arena.alloc(cdata.get_trait_def(def_id.index, tcx.sess))
}
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
adt_destructor => {
Expand All @@ -129,7 +129,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
bug!("get_optimized_mir: missing MIR for `{:?}`", def_id)
});

let mir = tcx.alloc_mir(mir);
let mir = tcx.arena.alloc(mir);

mir
}
Expand Down
Loading