From: achernyak Date: Tue, 2 May 2017 11:53:34 +0000 (-0500) Subject: query for deprecation X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=c1d97c7d5acf1a6250744a56dfd125cf534b61a4;p=rust.git query for deprecation --- diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index d05ede07c3f..0f31fae507e 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -151,6 +151,8 @@ pub enum DepNode { DescribeDef(D), DefSpan(D), + Stability(D), + Deprecation(D), } impl DepNode { @@ -258,6 +260,8 @@ pub fn map_def(&self, mut op: OP) -> Option> } DescribeDef(ref d) => op(d).map(DescribeDef), DefSpan(ref d) => op(d).map(DefSpan), + Stability(ref d) => op(d).map(Stability), + Deprecation(ref d) => op(d).map(Deprecation), } } } diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 50920ca7f7e..303c5059e7c 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -38,7 +38,6 @@ use std::path::PathBuf; use std::rc::Rc; use syntax::ast; -use syntax::attr; use syntax::ext::base::SyntaxExtension; use syntax::symbol::Symbol; use syntax_pos::Span; @@ -180,8 +179,6 @@ pub trait CrateStore { fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc; // item info - fn stability(&self, def: DefId) -> Option; - fn deprecation(&self, def: DefId) -> Option; fn visibility(&self, def: DefId) -> ty::Visibility; fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap>; fn item_generics_cloned(&self, def: DefId) -> ty::Generics; @@ -306,8 +303,6 @@ impl CrateStore for DummyCrateStore { fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc { bug!("crate_data_as_rc_any") } // item info - fn stability(&self, def: DefId) -> Option { bug!("stability") } - fn deprecation(&self, def: DefId) -> Option { bug!("deprecation") } fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") } fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap> { bug!("visible_parent_map") diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 1ac7f4fcc95..198f7420f5d 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -636,7 +636,7 @@ fn lookup_stability_uncached(self, id: DefId) -> Option<&'gcx Stability> { if id.is_local() { None // The stability cache is filled partially lazily } else { - self.sess.cstore.stability(id).map(|st| self.intern_stability(st)) + self.stability(id).map(|st| self.intern_stability(st)) } } @@ -645,7 +645,7 @@ fn lookup_deprecation_uncached(self, id: DefId) -> Option { if id.is_local() { None // The stability cache is filled partially lazily } else { - self.sess.cstore.deprecation(id).map(DeprecationEntry::external) + self.deprecation(id).map(DeprecationEntry::external) } } } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 3f18a480dd6..013e1646f2c 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -28,6 +28,7 @@ use std::ops::Deref; use std::rc::Rc; use syntax_pos::{Span, DUMMY_SP}; +use syntax::attr; use syntax::symbol::Symbol; trait Key { @@ -292,6 +293,19 @@ fn describe(_: TyCtxt, _: DefId) -> String { } } + +impl<'tcx> QueryDescription for queries::stability<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("stability") + } +} + +impl<'tcx> QueryDescription for queries::deprecation<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("deprecation") + } +} + impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> { fn describe(tcx: TyCtxt, def_id: DefId) -> String { format!("nested item bodies of `{}`", tcx.item_path_str(def_id)) @@ -599,7 +613,8 @@ fn default() -> Self { [] describe_def: DescribeDef(DefId) -> Option, [] def_span: DefSpan(DefId) -> Span, - + [] stability: Stability(DefId) -> Option, + [] deprecation: Deprecation(DefId) -> Option, [] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc>, [] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool, [] is_item_mir_available: metadata_dep_node(DefId) -> bool, diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index f5a8accea28..3c88aa25e98 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -115,6 +115,8 @@ pub fn provide<$lt>(providers: &mut Providers<$lt>) { is_foreign_item => { cdata.is_foreign_item(def_id.index) } describe_def => { cdata.get_def(def_id.index) } def_span => { cdata.get_span(def_id.index, &tcx.sess) } + stability => { cdata.get_stability(def_id.index) } + deprecation => { cdata.get_deprecation(def_id.index) } item_body_nested_bodies => { let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body)) @@ -137,16 +139,6 @@ fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc { self.get_crate_data(krate) } - fn stability(&self, def: DefId) -> Option { - self.dep_graph.read(DepNode::MetaData(def)); - self.get_crate_data(def.krate).get_stability(def.index) - } - - fn deprecation(&self, def: DefId) -> Option { - self.dep_graph.read(DepNode::MetaData(def)); - self.get_crate_data(def.krate).get_deprecation(def.index) - } - fn visibility(&self, def: DefId) -> ty::Visibility { self.dep_graph.read(DepNode::MetaData(def)); self.get_crate_data(def.krate).get_visibility(def.index)