@@ -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