Skip to content

Commit c63054d

Browse files
committed
Add method visibility to CrateStore
1 parent 45f0ce7 commit c63054d

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/librustc/middle/cstore.rs

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pub trait CrateStore<'tcx> : Any {
137137
// item info
138138
fn stability(&self, def: DefId) -> Option<attr::Stability>;
139139
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>;
140+
fn visibility(&self, def: DefId) -> hir::Visibility;
140141
fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
141142
-> ty::ClosureKind;
142143
fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
@@ -302,6 +303,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
302303
// item info
303304
fn stability(&self, def: DefId) -> Option<attr::Stability> { unimplemented!() }
304305
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { unimplemented!() }
306+
fn visibility(&self, def: DefId) -> hir::Visibility { unimplemented!() }
305307
fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
306308
-> ty::ClosureKind { unimplemented!() }
307309
fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)

src/librustc_metadata/csearch.rs

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
4949
decoder::get_deprecation(&cdata, def.index)
5050
}
5151

52+
fn visibility(&self, def: DefId) -> hir::Visibility {
53+
let cdata = self.get_crate_data(def.krate);
54+
decoder::get_visibility(&cdata, def.index)
55+
}
56+
5257
fn closure_kind(&self, _tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureKind
5358
{
5459
assert!(!def_id.is_local());

src/librustc_metadata/decoder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ pub fn get_deprecation(cdata: Cmd, id: DefIndex) -> Option<attr::Deprecation> {
545545
})
546546
}
547547

548+
pub fn get_visibility(cdata: Cmd, id: DefIndex) -> hir::Visibility {
549+
item_visibility(cdata.lookup_item(id))
550+
}
551+
548552
pub fn get_repr_attrs(cdata: Cmd, id: DefIndex) -> Vec<attr::ReprAttr> {
549553
let item = cdata.lookup_item(id);
550554
match reader::maybe_get_doc(item, tag_items_data_item_repr).map(|doc| {

0 commit comments

Comments
 (0)