@@ -14,7 +14,7 @@ use hir::def_id::{CRATE_DEF_INDEX, DefIndex, DefIndexAddressSpace};
1414use syntax:: ast:: * ;
1515use syntax:: ext:: hygiene:: Mark ;
1616use syntax:: visit;
17- use syntax:: symbol:: { Symbol , keywords} ;
17+ use syntax:: symbol:: keywords;
1818
1919use hir:: map:: { ITEM_LIKE_SPACE , REGULAR_SPACE } ;
2020
@@ -103,14 +103,14 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
103103 DefPathData :: Impl ,
104104 ItemKind :: Enum ( ..) | ItemKind :: Struct ( ..) | ItemKind :: Union ( ..) | ItemKind :: Trait ( ..) |
105105 ItemKind :: ExternCrate ( ..) | ItemKind :: ForeignMod ( ..) | ItemKind :: Ty ( ..) =>
106- DefPathData :: TypeNs ( i. ident . name . as_str ( ) ) ,
106+ DefPathData :: TypeNs ( i. ident . modern ( ) ) ,
107107 ItemKind :: Mod ( ..) if i. ident == keywords:: Invalid . ident ( ) => {
108108 return visit:: walk_item ( self , i) ;
109109 }
110- ItemKind :: Mod ( ..) => DefPathData :: Module ( i. ident . name . as_str ( ) ) ,
110+ ItemKind :: Mod ( ..) => DefPathData :: Module ( i. ident . modern ( ) ) ,
111111 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 ( ) ) ,
114114 ItemKind :: Mac ( ..) => return self . visit_macro_invoc ( i. id , false ) ,
115115 ItemKind :: GlobalAsm ( ..) => DefPathData :: Misc ,
116116 ItemKind :: Use ( ref view_path) => {
@@ -138,15 +138,13 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
138138 for v in & enum_definition. variants {
139139 let variant_def_index =
140140 this. create_def ( v. node . data . id ( ) ,
141- DefPathData :: EnumVariant ( v. node . name . name . as_str ( ) ) ,
141+ DefPathData :: EnumVariant ( v. node . name . modern ( ) ) ,
142142 REGULAR_SPACE ) ;
143143 this. with_parent ( variant_def_index, |this| {
144144 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 ) ;
150148 }
151149
152150 if let Some ( ref expr) = v. node . disr_expr {
@@ -164,9 +162,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
164162 }
165163
166164 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 ) ;
170168 }
171169 }
172170 _ => { }
@@ -177,7 +175,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
177175
178176 fn visit_foreign_item ( & mut self , foreign_item : & ' a ForeignItem ) {
179177 let def = self . create_def ( foreign_item. id ,
180- DefPathData :: ValueNs ( foreign_item. ident . name . as_str ( ) ) ,
178+ DefPathData :: ValueNs ( foreign_item. ident . modern ( ) ) ,
181179 REGULAR_SPACE ) ;
182180
183181 self . with_parent ( def, |this| {
@@ -188,7 +186,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
188186 fn visit_generics ( & mut self , generics : & ' a Generics ) {
189187 for ty_param in generics. ty_params . iter ( ) {
190188 self . create_def ( ty_param. id ,
191- DefPathData :: TypeParam ( ty_param. ident . name . as_str ( ) ) ,
189+ DefPathData :: TypeParam ( ty_param. ident . modern ( ) ) ,
192190 REGULAR_SPACE ) ;
193191 }
194192
@@ -198,8 +196,8 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
198196 fn visit_trait_item ( & mut self , ti : & ' a TraitItem ) {
199197 let def_data = match ti. node {
200198 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 ( ) ) ,
203201 TraitItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ti. id , false ) ,
204202 } ;
205203
@@ -216,8 +214,8 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
216214 fn visit_impl_item ( & mut self , ii : & ' a ImplItem ) {
217215 let def_data = match ii. node {
218216 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 ( ) ) ,
221219 ImplItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ii. id , false ) ,
222220 } ;
223221
@@ -238,7 +236,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
238236 PatKind :: Mac ( ..) => return self . visit_macro_invoc ( pat. id , false ) ,
239237 PatKind :: Ident ( _, id, _) => {
240238 let def = self . create_def ( pat. id ,
241- DefPathData :: Binding ( id. node . name . as_str ( ) ) ,
239+ DefPathData :: Binding ( id. node . modern ( ) ) ,
242240 REGULAR_SPACE ) ;
243241 self . parent_def = Some ( def) ;
244242 }
@@ -283,7 +281,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
283281
284282 fn visit_lifetime_def ( & mut self , def : & ' a LifetimeDef ) {
285283 self . create_def ( def. lifetime . id ,
286- DefPathData :: LifetimeDef ( def. lifetime . ident . name . as_str ( ) ) ,
284+ DefPathData :: LifetimeDef ( def. lifetime . ident . modern ( ) ) ,
287285 REGULAR_SPACE ) ;
288286 }
289287
0 commit comments