@@ -257,13 +257,13 @@ impl AssocItem {
257257/// it is relatively expensive. Instead, items are indexed by `Symbol` and hygienic comparison is
258258/// done only on items with the same name.
259259#[ derive( Debug , Clone , PartialEq , HashStable ) ]
260- pub struct AssociatedItems {
261- items : SortedIndexMultiMap < u32 , Symbol , ty:: AssocItem > ,
260+ pub struct AssociatedItems < ' tcx > {
261+ items : SortedIndexMultiMap < u32 , Symbol , & ' tcx ty:: AssocItem > ,
262262}
263263
264- impl AssociatedItems {
264+ impl < ' tcx > AssociatedItems < ' tcx > {
265265 /// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
266- pub fn new ( items_in_def_order : impl IntoIterator < Item = ty:: AssocItem > ) -> Self {
266+ pub fn new ( items_in_def_order : impl IntoIterator < Item = & ' tcx ty:: AssocItem > ) -> Self {
267267 let items = items_in_def_order. into_iter ( ) . map ( |item| ( item. ident . name , item) ) . collect ( ) ;
268268 AssociatedItems { items }
269269 }
@@ -273,15 +273,15 @@ impl AssociatedItems {
273273 /// New code should avoid relying on definition order. If you need a particular associated item
274274 /// for a known trait, make that trait a lang item instead of indexing this array.
275275 pub fn in_definition_order ( & self ) -> impl ' _ + Iterator < Item = & ty:: AssocItem > {
276- self . items . iter ( ) . map ( |( _, v) | v)
276+ self . items . iter ( ) . map ( |( _, v) | * v)
277277 }
278278
279279 /// Returns an iterator over all associated items with the given name, ignoring hygiene.
280280 pub fn filter_by_name_unhygienic (
281281 & self ,
282282 name : Symbol ,
283283 ) -> impl ' _ + Iterator < Item = & ty:: AssocItem > {
284- self . items . get_by_key ( & name)
284+ self . items . get_by_key ( & name) . map ( |v| * v )
285285 }
286286
287287 /// Returns an iterator over all associated items with the given name.
@@ -2672,7 +2672,7 @@ impl<'tcx> TyCtxt<'tcx> {
26722672 . and_then ( |def_id| self . hir ( ) . get ( self . hir ( ) . as_local_hir_id ( def_id) ) . ident ( ) )
26732673 }
26742674
2675- pub fn opt_associated_item ( self , def_id : DefId ) -> Option < AssocItem > {
2675+ pub fn opt_associated_item ( self , def_id : DefId ) -> Option < & ' tcx AssocItem > {
26762676 let is_associated_item = if let Some ( def_id) = def_id. as_local ( ) {
26772677 match self . hir ( ) . get ( self . hir ( ) . as_local_hir_id ( def_id) ) {
26782678 Node :: TraitItem ( _) | Node :: ImplItem ( _) => true ,
0 commit comments