@@ -257,13 +257,13 @@ impl AssocItem {
257
257
/// it is relatively expensive. Instead, items are indexed by `Symbol` and hygienic comparison is
258
258
/// done only on items with the same name.
259
259
#[ 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 > ,
262
262
}
263
263
264
- impl AssociatedItems {
264
+ impl < ' tcx > AssociatedItems < ' tcx > {
265
265
/// 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 {
267
267
let items = items_in_def_order. into_iter ( ) . map ( |item| ( item. ident . name , item) ) . collect ( ) ;
268
268
AssociatedItems { items }
269
269
}
@@ -273,15 +273,15 @@ impl AssociatedItems {
273
273
/// New code should avoid relying on definition order. If you need a particular associated item
274
274
/// for a known trait, make that trait a lang item instead of indexing this array.
275
275
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)
277
277
}
278
278
279
279
/// Returns an iterator over all associated items with the given name, ignoring hygiene.
280
280
pub fn filter_by_name_unhygienic (
281
281
& self ,
282
282
name : Symbol ,
283
283
) -> impl ' _ + Iterator < Item = & ty:: AssocItem > {
284
- self . items . get_by_key ( & name)
284
+ self . items . get_by_key ( & name) . map ( |v| * v )
285
285
}
286
286
287
287
/// Returns an iterator over all associated items with the given name.
@@ -2672,7 +2672,7 @@ impl<'tcx> TyCtxt<'tcx> {
2672
2672
. and_then ( |def_id| self . hir ( ) . get ( self . hir ( ) . as_local_hir_id ( def_id) ) . ident ( ) )
2673
2673
}
2674
2674
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 > {
2676
2676
let is_associated_item = if let Some ( def_id) = def_id. as_local ( ) {
2677
2677
match self . hir ( ) . get ( self . hir ( ) . as_local_hir_id ( def_id) ) {
2678
2678
Node :: TraitItem ( _) | Node :: ImplItem ( _) => true ,
0 commit comments