Skip to content

Commit

Permalink
Update rvalue_promotable_map
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Apr 25, 2019
1 parent b8b4ad5 commit d56d2fb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/librustc/arena.rs
Expand Up @@ -17,6 +17,7 @@ macro_rules! arena_types {
[few] mir_keys: rustc::util::nodemap::DefIdSet,
[decode] specialization_graph: rustc::traits::specialization_graph::Graph,
[] region_scope_tree: rustc::middle::region::ScopeTree,
[] item_local_set: rustc::util::nodemap::ItemLocalSet,
], $tcx);
)
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -17,7 +17,6 @@ use crate::middle::region;
use crate::ty::{self, DefIdTree, TyCtxt, adjustment};

use crate::hir::{self, PatKind};
use rustc_data_structures::sync::Lrc;
use std::rc::Rc;
use syntax::ptr::P;
use syntax_pos::Span;
Expand Down Expand Up @@ -272,7 +271,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<Lrc<ItemLocalSet>>)
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
-> Self
{
ExprUseVisitor {
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -77,7 +77,6 @@ use syntax_pos::Span;
use std::borrow::Cow;
use std::fmt;
use std::hash::{Hash, Hasher};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::indexed_vec::Idx;
use std::rc::Rc;
use crate::util::nodemap::ItemLocalSet;
Expand Down Expand Up @@ -290,7 +289,7 @@ pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub region_scope_tree: &'a region::ScopeTree,
pub tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<Lrc<ItemLocalSet>>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
infcx: Option<&'a InferCtxt<'a, 'gcx, 'tcx>>,
}

Expand Down Expand Up @@ -400,7 +399,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<Lrc<ItemLocalSet>>)
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
-> MemCategorizationContext<'a, 'tcx, 'tcx> {
MemCategorizationContext {
tcx,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Expand Up @@ -504,7 +504,7 @@ rustc_queries! {
}
cache { true }
}
query rvalue_promotable_map(key: DefId) -> Lrc<ItemLocalSet> {
query rvalue_promotable_map(key: DefId) -> &'tcx ItemLocalSet {
desc { |tcx|
"checking which parts of `{}` are promotable to static",
tcx.def_path_str(key)
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_passes/rvalue_promotion.rs
Expand Up @@ -25,7 +25,6 @@ use rustc::ty::query::Providers;
use rustc::ty::subst::{InternalSubsts, SubstsRef};
use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
use rustc::hir;
use rustc_data_structures::sync::Lrc;
use syntax_pos::{Span, DUMMY_SP};
use log::debug;
use Promotability::*;
Expand Down Expand Up @@ -53,7 +52,7 @@ fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId)
-> Lrc<ItemLocalSet>
-> &'tcx ItemLocalSet
{
let outer_def_id = tcx.closure_base_def_id(def_id);
if outer_def_id != def_id {
Expand All @@ -77,7 +76,7 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let body_id = tcx.hir().body_owned_by(hir_id);
let _ = visitor.check_nested_body(body_id);

Lrc::new(visitor.result)
tcx.arena.alloc(visitor.result)
}

struct CheckCrateVisitor<'a, 'tcx: 'a> {
Expand Down

0 comments on commit d56d2fb

Please sign in to comment.