@@ -63,6 +63,12 @@ pub struct Ident {
63
63
}
64
64
65
65
impl Ident {
66
+ /// Creates a HIR identifier with both `name` and `unhygienic_name` initialized with
67
+ /// the argument. Hygiene properties of the created identifier depend entirely on this
68
+ /// argument. If the argument is a plain interned string `intern("iter")`, then the result
69
+ /// is unhygienic and can interfere with other entities named "iter". If the argument is
70
+ /// a "fresh" name created with `gensym("iter")`, then the result is hygienic and can't
71
+ /// interfere with other entities having the same string as a name.
66
72
pub fn from_name ( name : Name ) -> Ident {
67
73
Ident { name : name, unhygienic_name : name }
68
74
}
@@ -157,6 +163,14 @@ impl fmt::Display for Path {
157
163
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
158
164
pub struct PathSegment {
159
165
/// The identifier portion of this path segment.
166
+ ///
167
+ /// Hygiene properties of this identifier are worth noting.
168
+ /// Most path segments are not hygienic and they are not renamed during
169
+ /// lowering from AST to HIR (see comments to `fn lower_path`). However segments from
170
+ /// unqualified paths with one segment originating from `ExprPath` (local-variable-like paths)
171
+ /// can be hygienic, so they are renamed. You should not normally care about this peculiarity
172
+ /// and just use `identifier.name` unless you modify identifier resolution code
173
+ /// (`fn resolve_identifier` and other functions called by it in `rustc_resolve`).
160
174
pub identifier : Ident ,
161
175
162
176
/// Type/lifetime parameters attached to this path. They come in
0 commit comments