diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-08-31 11:12:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-09-05 07:37:58 -0700 |
| commit | 84ae4b75be371844f9afb9f464f5064840ac3f9c (patch) | |
| tree | c4b7474d493149b7b1d2f895b7ed7c1f39c6e3f9 /src/librustc_metadata | |
| parent | 953490ddfa0561b21e56db6000fc2b3810ec0a91 (diff) | |
| download | rust-84ae4b75be371844f9afb9f464f5064840ac3f9c.tar.gz rust-84ae4b75be371844f9afb9f464f5064840ac3f9c.zip | |
rustc: Migrate `CrateStore::item_body` to a query
This commit migrates the `item_body` method on `CrateStore` to a query instead to enable better tracking of dependencies and whatnot.
Diffstat (limited to 'src/librustc_metadata')
| -rw-r--r-- | src/librustc_metadata/cstore_impl.rs | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 16cbc52ced9..7675a4f6e5f 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -214,6 +214,14 @@ provide! { <'tcx> tcx, def_id, other, cdata, } 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; + } + debug!("item_body({:?}): inlining item", def_id); + cdata.item_body(tcx, def_id.index) + } } pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) { @@ -397,21 +405,6 @@ impl CrateStore for cstore::CStore { }) } - fn item_body<'a, 'tcx>(&self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId) - -> &'tcx hir::Body { - self.read_dep_node(def_id); - - if let Some(cached) = tcx.hir.get_inlined_body_untracked(def_id) { - return cached; - } - - debug!("item_body({:?}): inlining item", def_id); - - self.get_crate_data(def_id.krate).item_body(tcx, def_id.index) - } - fn crates(&self) -> Vec<CrateNum> { let mut result = vec![]; |
