Skip to content

Commit 0182c8b

Browse files
committed
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.
1 parent 7d9c98e commit 0182c8b

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ define_dep_nodes!( <'tcx>
563563
[] GetLangItems,
564564
[] DefinedLangItems(CrateNum),
565565
[] MissingLangItems(CrateNum),
566-
[] ItemBody(DefId),
566+
[] ExternConstBody(DefId),
567567
[] VisibleParentMap,
568568
[] IsDirectExternCrate(CrateNum),
569569
[] MissingExternCrateItem(CrateNum),

src/librustc/ty/maps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ define_maps! { <'tcx>
13571357
[] get_lang_items: get_lang_items_node(CrateNum) -> Rc<LanguageItems>,
13581358
[] defined_lang_items: DefinedLangItems(CrateNum) -> Rc<Vec<(DefIndex, usize)>>,
13591359
[] missing_lang_items: MissingLangItems(CrateNum) -> Rc<Vec<LangItem>>,
1360-
[] item_body: ItemBody(DefId) -> &'tcx hir::Body,
1360+
[] extern_const_body: ExternConstBody(DefId) -> &'tcx hir::Body,
13611361
[] visible_parent_map: visible_parent_map_node(CrateNum)
13621362
-> Rc<DefIdMap<DefId>>,
13631363
[] missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,

src/librustc_const_eval/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
354354
}
355355
} else {
356356
if tcx.is_const_fn(def_id) {
357-
tcx.item_body(def_id)
357+
tcx.extern_const_body(def_id)
358358
} else {
359359
signal!(e, TypeckError)
360360
}
@@ -774,7 +774,7 @@ fn const_eval<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
774774
tcx.mir_const_qualif(def_id);
775775
tcx.hir.body(tcx.hir.body_owned_by(id))
776776
} else {
777-
tcx.item_body(def_id)
777+
tcx.extern_const_body(def_id)
778778
};
779779
ConstContext::new(tcx, key.param_env.and(substs), tables).eval(&body.value)
780780
}

src/librustc_const_eval/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
609609
let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
610610
self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
611611
} else {
612-
self.tcx.item_body(def_id)
612+
self.tcx.extern_const_body(def_id)
613613
};
614614
let pat = self.lower_const_expr(&body.value, pat_id, span);
615615
self.tables = old_tables;

src/librustc_metadata/cstore_impl.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
215215
defined_lang_items => { Rc::new(cdata.get_lang_items(&tcx.dep_graph)) }
216216
missing_lang_items => { Rc::new(cdata.get_missing_lang_items(&tcx.dep_graph)) }
217217

218-
item_body => {
219-
if let Some(cached) = tcx.hir.get_inlined_body_untracked(def_id) {
220-
return cached;
221-
}
218+
extern_const_body => {
222219
debug!("item_body({:?}): inlining item", def_id);
223-
cdata.item_body(tcx, def_id.index)
220+
cdata.extern_const_body(tcx, def_id.index)
224221
}
225222

226223
missing_extern_crate_item => {

src/librustc_metadata/decoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,10 @@ impl<'a, 'tcx> CrateMetadata {
759759
}
760760
}
761761

762-
pub fn item_body(&self,
763-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
764-
id: DefIndex)
765-
-> &'tcx hir::Body {
762+
pub fn extern_const_body(&self,
763+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
764+
id: DefIndex)
765+
-> &'tcx hir::Body {
766766
assert!(!self.is_proc_macro(id));
767767
let ast = self.entry(id).ast.unwrap();
768768
let def_id = self.local_def_id(id);

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl hir::print::PpAnn for InlinedConst {
474474
}
475475

476476
fn print_inlined_const(cx: &DocContext, did: DefId) -> String {
477-
let body = cx.tcx.item_body(did);
477+
let body = cx.tcx.extern_const_body(did);
478478
let inlined = InlinedConst {
479479
nested_bodies: cx.tcx.item_body_nested_bodies(did)
480480
};

0 commit comments

Comments
 (0)