提交 0182c8bb 编写于 作者: A Alex Crichton

rustc: Rename item_body query to extern_const_body

Should hopefully more accurately reflect what's happening! This commit also
removes the cache in the cstore implementation as it's already cached through
the query infrastructure.
上级 7d9c98e4
......@@ -563,7 +563,7 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
[] GetLangItems,
[] DefinedLangItems(CrateNum),
[] MissingLangItems(CrateNum),
[] ItemBody(DefId),
[] ExternConstBody(DefId),
[] VisibleParentMap,
[] IsDirectExternCrate(CrateNum),
[] MissingExternCrateItem(CrateNum),
......
......@@ -1357,7 +1357,7 @@ fn default() -> Self {
[] get_lang_items: get_lang_items_node(CrateNum) -> Rc<LanguageItems>,
[] defined_lang_items: DefinedLangItems(CrateNum) -> Rc<Vec<(DefIndex, usize)>>,
[] missing_lang_items: MissingLangItems(CrateNum) -> Rc<Vec<LangItem>>,
[] item_body: ItemBody(DefId) -> &'tcx hir::Body,
[] extern_const_body: ExternConstBody(DefId) -> &'tcx hir::Body,
[] visible_parent_map: visible_parent_map_node(CrateNum)
-> Rc<DefIdMap<DefId>>,
[] missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
......
......@@ -354,7 +354,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
}
} else {
if tcx.is_const_fn(def_id) {
tcx.item_body(def_id)
tcx.extern_const_body(def_id)
} else {
signal!(e, TypeckError)
}
......@@ -774,7 +774,7 @@ fn const_eval<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.mir_const_qualif(def_id);
tcx.hir.body(tcx.hir.body_owned_by(id))
} else {
tcx.item_body(def_id)
tcx.extern_const_body(def_id)
};
ConstContext::new(tcx, key.param_env.and(substs), tables).eval(&body.value)
}
......@@ -609,7 +609,7 @@ fn lower_path(&mut self,
let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
} else {
self.tcx.item_body(def_id)
self.tcx.extern_const_body(def_id)
};
let pat = self.lower_const_expr(&body.value, pat_id, span);
self.tables = old_tables;
......
......@@ -215,12 +215,9 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) }
defined_lang_items => { Rc::new(cdata.get_lang_items(&tcx.dep_graph)) }
missing_lang_items => { Rc::new(cdata.get_missing_lang_items(&tcx.dep_graph)) }
item_body => {
if let Some(cached) = tcx.hir.get_inlined_body_untracked(def_id) {
return cached;
}
extern_const_body => {
debug!("item_body({:?}): inlining item", def_id);
cdata.item_body(tcx, def_id.index)
cdata.extern_const_body(tcx, def_id.index)
}
missing_extern_crate_item => {
......
......@@ -759,10 +759,10 @@ pub fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Sessio
}
}
pub fn item_body(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: DefIndex)
-> &'tcx hir::Body {
pub fn extern_const_body(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: DefIndex)
-> &'tcx hir::Body {
assert!(!self.is_proc_macro(id));
let ast = self.entry(id).ast.unwrap();
let def_id = self.local_def_id(id);
......
......@@ -474,7 +474,7 @@ fn nested(&self, state: &mut hir::print::State, nested: hir::print::Nested)
}
fn print_inlined_const(cx: &DocContext, did: DefId) -> String {
let body = cx.tcx.item_body(did);
let body = cx.tcx.extern_const_body(did);
let inlined = InlinedConst {
nested_bodies: cx.tcx.item_body_nested_bodies(did)
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册