Skip to content
Permalink
Browse files

Update mir_const_qualif

  • Loading branch information...
Zoxc committed Nov 30, 2018
1 parent d56d2fb commit 1fe0d4e3839883bb88777173cd7775425a251085
@@ -18,6 +18,7 @@ macro_rules! arena_types {
[decode] specialization_graph: rustc::traits::specialization_graph::Graph,
[] region_scope_tree: rustc::middle::region::ScopeTree,
[] item_local_set: rustc::util::nodemap::ItemLocalSet,
[decode] mir_const_qualif: rustc_data_structures::bit_set::BitSet<rustc::mir::Local>,
], $tcx);
)
}
@@ -91,7 +91,7 @@ rustc_queries! {
/// Maps DefId's that have an associated Mir to the result
/// of the MIR qualify_consts pass. The actual meaning of
/// the value isn't known except to the pass itself.
query mir_const_qualif(key: DefId) -> (u8, Lrc<BitSet<mir::Local>>) {
query mir_const_qualif(key: DefId) -> (u8, &'tcx BitSet<mir::Local>) {
cache { key.is_local() }
}

@@ -131,7 +131,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
mir
}
mir_const_qualif => {
(cdata.mir_const_qualif(def_id.index), Lrc::new(BitSet::new_empty(0)))
(cdata.mir_const_qualif(def_id.index), tcx.arena.alloc(BitSet::new_empty(0)))
}
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
@@ -7,7 +7,6 @@
use rustc_data_structures::bit_set::BitSet;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
use rustc_target::spec::abi::Abi;
use rustc::hir;
use rustc::hir::def_id::DefId;
@@ -833,7 +832,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
}

/// Check a whole const, static initializer or const fn.
fn check_const(&mut self) -> (u8, Lrc<BitSet<Local>>) {
fn check_const(&mut self) -> (u8, &'tcx BitSet<Local>) {
debug!("const-checking {} {:?}", self.mode, self.def_id);

let mir = self.mir;
@@ -907,8 +906,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
}
}

let promoted_temps = Lrc::new(promoted_temps);

let mut qualifs = self.qualifs_in_local(RETURN_PLACE);

// Account for errors in consts by using the
@@ -917,7 +914,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
qualifs = self.qualifs_in_any_value_of_ty(mir.return_ty());
}

(qualifs.encode_to_bits(), promoted_temps)
(qualifs.encode_to_bits(), self.tcx.arena.alloc(promoted_temps))
}
}

@@ -1433,7 +1430,7 @@ pub fn provide(providers: &mut Providers<'_>) {

fn mir_const_qualif<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId)
-> (u8, Lrc<BitSet<Local>>) {
-> (u8, &'tcx BitSet<Local>) {
// N.B., this `borrow()` is guaranteed to be valid (i.e., the value
// cannot yet be stolen), because `mir_validated()`, which steals
// from `mir_const(), forces this query to execute before
@@ -1442,7 +1439,7 @@ fn mir_const_qualif<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

if mir.return_ty().references_error() {
tcx.sess.delay_span_bug(mir.span, "mir_const_qualif: Mir had errors");
return (1 << IsNotPromotable::IDX, Lrc::new(BitSet::new_empty(0)));
return (1 << IsNotPromotable::IDX, tcx.arena.alloc(BitSet::new_empty(0)));
}

Checker::new(tcx, def_id, mir, Mode::Const).check_const()

0 comments on commit 1fe0d4e

Please sign in to comment.
You can’t perform that action at this time.