Skip to content

Commit f418f1d

Browse files
committed
Remove attribute_cache from CrateMetadata
1 parent df40e61 commit f418f1d

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

src/librustc_metadata/creader.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ impl<'a> CrateLoader<'a> {
243243
cnum,
244244
dependencies: Lock::new(dependencies),
245245
codemap_import_info: RwLock::new(vec![]),
246-
attribute_cache: Lock::new([Vec::new(), Vec::new()]),
247246
dep_kind: Lock::new(dep_kind),
248247
source: cstore::CrateSource {
249248
dylib,

src/librustc_metadata/cstore.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pub struct CrateMetadata {
6969
pub cnum: CrateNum,
7070
pub dependencies: Lock<Vec<CrateNum>>,
7171
pub codemap_import_info: RwLock<Vec<ImportedFileMap>>,
72-
pub attribute_cache: Lock<[Vec<Option<Lrc<[ast::Attribute]>>>; 2]>,
7372

7473
pub root: schema::CrateRoot,
7574

src/librustc_metadata/decoder.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -880,34 +880,22 @@ impl<'a, 'tcx> CrateMetadata {
880880
}
881881

882882
pub fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> {
883-
let (node_as, node_index) =
884-
(node_id.address_space().index(), node_id.as_array_index());
885883
if self.is_proc_macro(node_id) {
886884
return Lrc::new([]);
887885
}
888886

889-
if let Some(&Some(ref val)) =
890-
self.attribute_cache.borrow()[node_as].get(node_index) {
891-
return val.clone();
892-
}
893-
894887
// The attributes for a tuple struct are attached to the definition, not the ctor;
895888
// we assume that someone passing in a tuple struct ctor is actually wanting to
896889
// look at the definition
897-
let mut item = self.entry(node_id);
898890
let def_key = self.def_key(node_id);
899-
if def_key.disambiguated_data.data == DefPathData::StructCtor {
900-
item = self.entry(def_key.parent.unwrap());
901-
}
902-
let result: Lrc<[ast::Attribute]> = Lrc::from(self.get_attributes(&item, sess));
903-
let vec_ = &mut self.attribute_cache.borrow_mut()[node_as];
904-
if vec_.len() < node_index + 1 {
905-
vec_.resize(node_index + 1, None);
906-
}
907-
// This can overwrite the result produced by another thread, but the value
908-
// written should be the same
909-
vec_[node_index] = Some(result.clone());
910-
result
891+
let item_id = if def_key.disambiguated_data.data == DefPathData::StructCtor {
892+
def_key.parent.unwrap()
893+
} else {
894+
node_id
895+
};
896+
897+
let item = self.entry(item_id);
898+
Lrc::from(self.get_attributes(&item, sess))
911899
}
912900

913901
pub fn get_struct_field_names(&self, id: DefIndex) -> Vec<ast::Name> {

0 commit comments

Comments
 (0)