@@ -44,8 +44,7 @@ impl AssocItemContainer {
4444#[ derive( Copy , Clone , Debug , PartialEq , HashStable , Eq , Hash ) ]
4545pub struct AssocItem {
4646 pub def_id : DefId ,
47- #[ stable_hasher( project( name) ) ]
48- pub ident : Ident ,
47+ pub name : Symbol ,
4948 pub kind : AssocKind ,
5049 pub vis : Visibility ,
5150 pub defaultness : hir:: Defaultness ,
@@ -61,6 +60,10 @@ pub struct AssocItem {
6160}
6261
6362impl AssocItem {
63+ pub fn ident ( & self , tcx : TyCtxt < ' _ > ) -> Ident {
64+ Ident :: new ( self . name , tcx. def_ident_span ( self . def_id ) . unwrap ( ) )
65+ }
66+
6467 pub fn signature ( & self , tcx : TyCtxt < ' _ > ) -> String {
6568 match self . kind {
6669 ty:: AssocKind :: Fn => {
@@ -70,9 +73,9 @@ impl AssocItem {
7073 // regions just fine, showing `fn(&MyType)`.
7174 tcx. fn_sig ( self . def_id ) . skip_binder ( ) . to_string ( )
7275 }
73- ty:: AssocKind :: Type => format ! ( "type {};" , self . ident ) ,
76+ ty:: AssocKind :: Type => format ! ( "type {};" , self . name ) ,
7477 ty:: AssocKind :: Const => {
75- format ! ( "const {}: {:?};" , self . ident , tcx. type_of( self . def_id) )
78+ format ! ( "const {}: {:?};" , self . name , tcx. type_of( self . def_id) )
7679 }
7780 }
7881 }
@@ -115,7 +118,7 @@ pub struct AssocItems<'tcx> {
115118impl < ' tcx > AssocItems < ' tcx > {
116119 /// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
117120 pub fn new ( items_in_def_order : impl IntoIterator < Item = & ' tcx ty:: AssocItem > ) -> Self {
118- let items = items_in_def_order. into_iter ( ) . map ( |item| ( item. ident . name , item) ) . collect ( ) ;
121+ let items = items_in_def_order. into_iter ( ) . map ( |item| ( item. name , item) ) . collect ( ) ;
119122 AssocItems { items }
120123 }
121124
@@ -149,7 +152,7 @@ impl<'tcx> AssocItems<'tcx> {
149152 ) -> Option < & ty:: AssocItem > {
150153 self . filter_by_name_unhygienic ( ident. name )
151154 . filter ( |item| item. kind == kind)
152- . find ( |item| tcx. hygienic_eq ( ident, item. ident , parent_def_id) )
155+ . find ( |item| tcx. hygienic_eq ( ident, item. ident ( tcx ) , parent_def_id) )
153156 }
154157
155158 /// Returns the associated item with the given name and any of `AssocKind`, if one exists.
@@ -162,7 +165,7 @@ impl<'tcx> AssocItems<'tcx> {
162165 ) -> Option < & ty:: AssocItem > {
163166 self . filter_by_name_unhygienic ( ident. name )
164167 . filter ( |item| kinds. contains ( & item. kind ) )
165- . find ( |item| tcx. hygienic_eq ( ident, item. ident , parent_def_id) )
168+ . find ( |item| tcx. hygienic_eq ( ident, item. ident ( tcx ) , parent_def_id) )
166169 }
167170
168171 /// Returns the associated item with the given name in the given `Namespace`, if one exists.
@@ -175,6 +178,6 @@ impl<'tcx> AssocItems<'tcx> {
175178 ) -> Option < & ty:: AssocItem > {
176179 self . filter_by_name_unhygienic ( ident. name )
177180 . filter ( |item| item. kind . namespace ( ) == ns)
178- . find ( |item| tcx. hygienic_eq ( ident, item. ident , parent_def_id) )
181+ . find ( |item| tcx. hygienic_eq ( ident, item. ident ( tcx ) , parent_def_id) )
179182 }
180183}
0 commit comments