Skip to content

Commit c1d97c7

Browse files
committed
query for deprecation
1 parent 33535af commit c1d97c7

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

src/librustc/dep_graph/dep_node.rs

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ pub enum DepNode<D: Clone + Debug> {
151151

152152
DescribeDef(D),
153153
DefSpan(D),
154+
Stability(D),
155+
Deprecation(D),
154156
}
155157

156158
impl<D: Clone + Debug> DepNode<D> {
@@ -258,6 +260,8 @@ impl<D: Clone + Debug> DepNode<D> {
258260
}
259261
DescribeDef(ref d) => op(d).map(DescribeDef),
260262
DefSpan(ref d) => op(d).map(DefSpan),
263+
Stability(ref d) => op(d).map(Stability),
264+
Deprecation(ref d) => op(d).map(Deprecation),
261265
}
262266
}
263267
}

src/librustc/middle/cstore.rs

-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use std::any::Any;
3838
use std::path::PathBuf;
3939
use std::rc::Rc;
4040
use syntax::ast;
41-
use syntax::attr;
4241
use syntax::ext::base::SyntaxExtension;
4342
use syntax::symbol::Symbol;
4443
use syntax_pos::Span;
@@ -180,8 +179,6 @@ pub trait CrateStore {
180179
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any>;
181180

182181
// item info
183-
fn stability(&self, def: DefId) -> Option<attr::Stability>;
184-
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>;
185182
fn visibility(&self, def: DefId) -> ty::Visibility;
186183
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
187184
fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
@@ -306,8 +303,6 @@ impl CrateStore for DummyCrateStore {
306303
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any>
307304
{ bug!("crate_data_as_rc_any") }
308305
// item info
309-
fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
310-
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
311306
fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
312307
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>> {
313308
bug!("visible_parent_map")

src/librustc/middle/stability.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
636636
if id.is_local() {
637637
None // The stability cache is filled partially lazily
638638
} else {
639-
self.sess.cstore.stability(id).map(|st| self.intern_stability(st))
639+
self.stability(id).map(|st| self.intern_stability(st))
640640
}
641641
}
642642

@@ -645,7 +645,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
645645
if id.is_local() {
646646
None // The stability cache is filled partially lazily
647647
} else {
648-
self.sess.cstore.deprecation(id).map(DeprecationEntry::external)
648+
self.deprecation(id).map(DeprecationEntry::external)
649649
}
650650
}
651651
}

src/librustc/ty/maps.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use std::collections::BTreeMap;
2828
use std::ops::Deref;
2929
use std::rc::Rc;
3030
use syntax_pos::{Span, DUMMY_SP};
31+
use syntax::attr;
3132
use syntax::symbol::Symbol;
3233

3334
trait Key {
@@ -292,6 +293,19 @@ impl<'tcx> QueryDescription for queries::def_span<'tcx> {
292293
}
293294
}
294295

296+
297+
impl<'tcx> QueryDescription for queries::stability<'tcx> {
298+
fn describe(_: TyCtxt, _: DefId) -> String {
299+
bug!("stability")
300+
}
301+
}
302+
303+
impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
304+
fn describe(_: TyCtxt, _: DefId) -> String {
305+
bug!("deprecation")
306+
}
307+
}
308+
295309
impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
296310
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
297311
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
@@ -599,7 +613,8 @@ define_maps! { <'tcx>
599613

600614
[] describe_def: DescribeDef(DefId) -> Option<Def>,
601615
[] def_span: DefSpan(DefId) -> Span,
602-
616+
[] stability: Stability(DefId) -> Option<attr::Stability>,
617+
[] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
603618
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
604619
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
605620
[] is_item_mir_available: metadata_dep_node(DefId) -> bool,

src/librustc_metadata/cstore_impl.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ provide! { <'tcx> tcx, def_id, cdata
115115
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
116116
describe_def => { cdata.get_def(def_id.index) }
117117
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
118+
stability => { cdata.get_stability(def_id.index) }
119+
deprecation => { cdata.get_deprecation(def_id.index) }
118120
item_body_nested_bodies => {
119121
let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| {
120122
ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body))
@@ -137,16 +139,6 @@ impl CrateStore for cstore::CStore {
137139
self.get_crate_data(krate)
138140
}
139141

140-
fn stability(&self, def: DefId) -> Option<attr::Stability> {
141-
self.dep_graph.read(DepNode::MetaData(def));
142-
self.get_crate_data(def.krate).get_stability(def.index)
143-
}
144-
145-
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> {
146-
self.dep_graph.read(DepNode::MetaData(def));
147-
self.get_crate_data(def.krate).get_deprecation(def.index)
148-
}
149-
150142
fn visibility(&self, def: DefId) -> ty::Visibility {
151143
self.dep_graph.read(DepNode::MetaData(def));
152144
self.get_crate_data(def.krate).get_visibility(def.index)

0 commit comments

Comments
 (0)