@@ -39,7 +39,7 @@ use intravisit::Visitor;
3939use std:: collections:: BTreeMap ;
4040use syntax:: codemap:: { self , Span , Spanned , DUMMY_SP , ExpnId } ;
4141use 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 } ;
4343use syntax:: ast:: { Attribute , Lit , StrStyle , FloatTy , IntTy , UintTy , CrateConfig } ;
4444use syntax:: attr:: ThinAttributes ;
4545use syntax:: owned_slice:: OwnedSlice ;
@@ -50,7 +50,59 @@ use print::pprust;
5050use util;
5151
5252use 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+ }
54106
55107#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Copy ) ]
56108pub struct Lifetime {
0 commit comments