Skip to content

Commit

Permalink
Update mir_const_qualif
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Apr 25, 2019
1 parent d56d2fb commit 1fe0d4e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/librustc/arena.rs
Expand Up @@ -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);
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Expand Up @@ -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() }
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore_impl.rs
Expand Up @@ -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)) }
Expand Down
11 changes: 4 additions & 7 deletions src/librustc_mir/transform/qualify_consts.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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))
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 1fe0d4e

Please sign in to comment.