@@ -44,8 +44,7 @@ impl AssocItemContainer {
44
44
#[ derive( Copy , Clone , Debug , PartialEq , HashStable , Eq , Hash ) ]
45
45
pub struct AssocItem {
46
46
pub def_id : DefId ,
47
- #[ stable_hasher( project( name) ) ]
48
- pub ident : Ident ,
47
+ pub name : Symbol ,
49
48
pub kind : AssocKind ,
50
49
pub vis : Visibility ,
51
50
pub defaultness : hir:: Defaultness ,
@@ -61,6 +60,10 @@ pub struct AssocItem {
61
60
}
62
61
63
62
impl AssocItem {
63
+ pub fn ident ( & self , tcx : TyCtxt < ' _ > ) -> Ident {
64
+ Ident :: new ( self . name , tcx. def_ident_span ( self . def_id ) . unwrap ( ) )
65
+ }
66
+
64
67
pub fn signature ( & self , tcx : TyCtxt < ' _ > ) -> String {
65
68
match self . kind {
66
69
ty:: AssocKind :: Fn => {
@@ -70,9 +73,9 @@ impl AssocItem {
70
73
// regions just fine, showing `fn(&MyType)`.
71
74
tcx. fn_sig ( self . def_id ) . skip_binder ( ) . to_string ( )
72
75
}
73
- ty:: AssocKind :: Type => format ! ( "type {};" , self . ident ) ,
76
+ ty:: AssocKind :: Type => format ! ( "type {};" , self . name ) ,
74
77
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) )
76
79
}
77
80
}
78
81
}
@@ -115,7 +118,7 @@ pub struct AssocItems<'tcx> {
115
118
impl < ' tcx > AssocItems < ' tcx > {
116
119
/// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
117
120
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 ( ) ;
119
122
AssocItems { items }
120
123
}
121
124
@@ -149,7 +152,7 @@ impl<'tcx> AssocItems<'tcx> {
149
152
) -> Option < & ty:: AssocItem > {
150
153
self . filter_by_name_unhygienic ( ident. name )
151
154
. 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) )
153
156
}
154
157
155
158
/// Returns the associated item with the given name and any of `AssocKind`, if one exists.
@@ -162,7 +165,7 @@ impl<'tcx> AssocItems<'tcx> {
162
165
) -> Option < & ty:: AssocItem > {
163
166
self . filter_by_name_unhygienic ( ident. name )
164
167
. 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) )
166
169
}
167
170
168
171
/// Returns the associated item with the given name in the given `Namespace`, if one exists.
@@ -175,6 +178,6 @@ impl<'tcx> AssocItems<'tcx> {
175
178
) -> Option < & ty:: AssocItem > {
176
179
self . filter_by_name_unhygienic ( ident. name )
177
180
. 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) )
179
182
}
180
183
}
0 commit comments