@@ -14,7 +14,7 @@ use hir::def_id::{CRATE_DEF_INDEX, DefIndex, DefIndexAddressSpace};
14
14
use syntax:: ast:: * ;
15
15
use syntax:: ext:: hygiene:: Mark ;
16
16
use syntax:: visit;
17
- use syntax:: symbol:: { Symbol , keywords} ;
17
+ use syntax:: symbol:: keywords;
18
18
19
19
use hir:: map:: { ITEM_LIKE_SPACE , REGULAR_SPACE } ;
20
20
@@ -103,14 +103,14 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
103
103
DefPathData :: Impl ,
104
104
ItemKind :: Enum ( ..) | ItemKind :: Struct ( ..) | ItemKind :: Union ( ..) | ItemKind :: Trait ( ..) |
105
105
ItemKind :: ExternCrate ( ..) | ItemKind :: ForeignMod ( ..) | ItemKind :: Ty ( ..) =>
106
- DefPathData :: TypeNs ( i. ident . name . as_str ( ) ) ,
106
+ DefPathData :: TypeNs ( i. ident . modern ( ) ) ,
107
107
ItemKind :: Mod ( ..) if i. ident == keywords:: Invalid . ident ( ) => {
108
108
return visit:: walk_item ( self , i) ;
109
109
}
110
- ItemKind :: Mod ( ..) => DefPathData :: Module ( i. ident . name . as_str ( ) ) ,
110
+ ItemKind :: Mod ( ..) => DefPathData :: Module ( i. ident . modern ( ) ) ,
111
111
ItemKind :: Static ( ..) | ItemKind :: Const ( ..) | ItemKind :: Fn ( ..) =>
112
- DefPathData :: ValueNs ( i. ident . name . as_str ( ) ) ,
113
- ItemKind :: MacroDef ( ..) => DefPathData :: MacroDef ( i. ident . name . as_str ( ) ) ,
112
+ DefPathData :: ValueNs ( i. ident . modern ( ) ) ,
113
+ ItemKind :: MacroDef ( ..) => DefPathData :: MacroDef ( i. ident . modern ( ) ) ,
114
114
ItemKind :: Mac ( ..) => return self . visit_macro_invoc ( i. id , false ) ,
115
115
ItemKind :: GlobalAsm ( ..) => DefPathData :: Misc ,
116
116
ItemKind :: Use ( ref view_path) => {
@@ -138,15 +138,13 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
138
138
for v in & enum_definition. variants {
139
139
let variant_def_index =
140
140
this. create_def ( v. node . data . id ( ) ,
141
- DefPathData :: EnumVariant ( v. node . name . name . as_str ( ) ) ,
141
+ DefPathData :: EnumVariant ( v. node . name . modern ( ) ) ,
142
142
REGULAR_SPACE ) ;
143
143
this. with_parent ( variant_def_index, |this| {
144
144
for ( index, field) in v. node . data . fields ( ) . iter ( ) . enumerate ( ) {
145
- let name = field. ident . map ( |ident| ident. name )
146
- . unwrap_or_else ( || Symbol :: intern ( & index. to_string ( ) ) ) ;
147
- this. create_def ( field. id ,
148
- DefPathData :: Field ( name. as_str ( ) ) ,
149
- REGULAR_SPACE ) ;
145
+ let ident = field. ident . map ( Ident :: modern)
146
+ . unwrap_or_else ( || Ident :: from_str ( & index. to_string ( ) ) ) ;
147
+ this. create_def ( field. id , DefPathData :: Field ( ident) , REGULAR_SPACE ) ;
150
148
}
151
149
152
150
if let Some ( ref expr) = v. node . disr_expr {
@@ -164,9 +162,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
164
162
}
165
163
166
164
for ( index, field) in struct_def. fields ( ) . iter ( ) . enumerate ( ) {
167
- let name = field. ident . map ( |ident| ident . name . as_str ( ) )
168
- . unwrap_or ( Symbol :: intern ( & index. to_string ( ) ) . as_str ( ) ) ;
169
- this. create_def ( field. id , DefPathData :: Field ( name ) , REGULAR_SPACE ) ;
165
+ let ident = field. ident . map ( Ident :: modern )
166
+ . unwrap_or_else ( || Ident :: from_str ( & index. to_string ( ) ) ) ;
167
+ this. create_def ( field. id , DefPathData :: Field ( ident ) , REGULAR_SPACE ) ;
170
168
}
171
169
}
172
170
_ => { }
@@ -177,7 +175,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
177
175
178
176
fn visit_foreign_item ( & mut self , foreign_item : & ' a ForeignItem ) {
179
177
let def = self . create_def ( foreign_item. id ,
180
- DefPathData :: ValueNs ( foreign_item. ident . name . as_str ( ) ) ,
178
+ DefPathData :: ValueNs ( foreign_item. ident . modern ( ) ) ,
181
179
REGULAR_SPACE ) ;
182
180
183
181
self . with_parent ( def, |this| {
@@ -188,7 +186,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
188
186
fn visit_generics ( & mut self , generics : & ' a Generics ) {
189
187
for ty_param in generics. ty_params . iter ( ) {
190
188
self . create_def ( ty_param. id ,
191
- DefPathData :: TypeParam ( ty_param. ident . name . as_str ( ) ) ,
189
+ DefPathData :: TypeParam ( ty_param. ident . modern ( ) ) ,
192
190
REGULAR_SPACE ) ;
193
191
}
194
192
@@ -198,8 +196,8 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
198
196
fn visit_trait_item ( & mut self , ti : & ' a TraitItem ) {
199
197
let def_data = match ti. node {
200
198
TraitItemKind :: Method ( ..) | TraitItemKind :: Const ( ..) =>
201
- DefPathData :: ValueNs ( ti. ident . name . as_str ( ) ) ,
202
- TraitItemKind :: Type ( ..) => DefPathData :: TypeNs ( ti. ident . name . as_str ( ) ) ,
199
+ DefPathData :: ValueNs ( ti. ident . modern ( ) ) ,
200
+ TraitItemKind :: Type ( ..) => DefPathData :: TypeNs ( ti. ident . modern ( ) ) ,
203
201
TraitItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ti. id , false ) ,
204
202
} ;
205
203
@@ -216,8 +214,8 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
216
214
fn visit_impl_item ( & mut self , ii : & ' a ImplItem ) {
217
215
let def_data = match ii. node {
218
216
ImplItemKind :: Method ( ..) | ImplItemKind :: Const ( ..) =>
219
- DefPathData :: ValueNs ( ii. ident . name . as_str ( ) ) ,
220
- ImplItemKind :: Type ( ..) => DefPathData :: TypeNs ( ii. ident . name . as_str ( ) ) ,
217
+ DefPathData :: ValueNs ( ii. ident . modern ( ) ) ,
218
+ ImplItemKind :: Type ( ..) => DefPathData :: TypeNs ( ii. ident . modern ( ) ) ,
221
219
ImplItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ii. id , false ) ,
222
220
} ;
223
221
@@ -238,7 +236,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
238
236
PatKind :: Mac ( ..) => return self . visit_macro_invoc ( pat. id , false ) ,
239
237
PatKind :: Ident ( _, id, _) => {
240
238
let def = self . create_def ( pat. id ,
241
- DefPathData :: Binding ( id. node . name . as_str ( ) ) ,
239
+ DefPathData :: Binding ( id. node . modern ( ) ) ,
242
240
REGULAR_SPACE ) ;
243
241
self . parent_def = Some ( def) ;
244
242
}
@@ -283,7 +281,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
283
281
284
282
fn visit_lifetime_def ( & mut self , def : & ' a LifetimeDef ) {
285
283
self . create_def ( def. lifetime . id ,
286
- DefPathData :: LifetimeDef ( def. lifetime . ident . name . as_str ( ) ) ,
284
+ DefPathData :: LifetimeDef ( def. lifetime . ident . modern ( ) ) ,
287
285
REGULAR_SPACE ) ;
288
286
}
289
287
0 commit comments