@@ -39,7 +39,7 @@ use intravisit::Visitor;
39
39
use std:: collections:: BTreeMap ;
40
40
use syntax:: codemap:: { self , Span , Spanned , DUMMY_SP , ExpnId } ;
41
41
use syntax:: abi:: Abi ;
42
- use syntax:: ast:: { Name , Ident , NodeId , DUMMY_NODE_ID , TokenTree , AsmDialect } ;
42
+ use syntax:: ast:: { Name , NodeId , DUMMY_NODE_ID , TokenTree , AsmDialect } ;
43
43
use syntax:: ast:: { Attribute , Lit , StrStyle , FloatTy , IntTy , UintTy , CrateConfig } ;
44
44
use syntax:: attr:: ThinAttributes ;
45
45
use syntax:: owned_slice:: OwnedSlice ;
@@ -50,7 +50,59 @@ use print::pprust;
50
50
use util;
51
51
52
52
use std:: fmt;
53
- use serialize:: { Encodable , Encoder , Decoder } ;
53
+ use std:: hash:: { Hash , Hasher } ;
54
+ use serialize:: { Encodable , Decodable , Encoder , Decoder } ;
55
+
56
+ /// Identifier in HIR
57
+ #[ derive( Clone , Copy , Eq ) ]
58
+ pub struct Ident {
59
+ /// Hygienic name (renamed), should be used by default
60
+ pub name : Name ,
61
+ /// Unhygienic name (original, not renamed), needed in few places in name resolution
62
+ pub unhygienic_name : Name ,
63
+ }
64
+
65
+ impl Ident {
66
+ pub fn from_name ( name : Name ) -> Ident {
67
+ Ident { name : name, unhygienic_name : name }
68
+ }
69
+ }
70
+
71
+ impl PartialEq for Ident {
72
+ fn eq ( & self , other : & Ident ) -> bool {
73
+ self . name == other. name
74
+ }
75
+ }
76
+
77
+ impl Hash for Ident {
78
+ fn hash < H : Hasher > ( & self , state : & mut H ) {
79
+ self . name . hash ( state)
80
+ }
81
+ }
82
+
83
+ impl fmt:: Debug for Ident {
84
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
85
+ fmt:: Debug :: fmt ( & self . name , f)
86
+ }
87
+ }
88
+
89
+ impl fmt:: Display for Ident {
90
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
91
+ fmt:: Display :: fmt ( & self . name , f)
92
+ }
93
+ }
94
+
95
+ impl Encodable for Ident {
96
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
97
+ self . name . encode ( s)
98
+ }
99
+ }
100
+
101
+ impl Decodable for Ident {
102
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < Ident , D :: Error > {
103
+ Ok ( Ident :: from_name ( try!( Name :: decode ( d) ) ) )
104
+ }
105
+ }
54
106
55
107
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Copy ) ]
56
108
pub struct Lifetime {
0 commit comments