about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-12-07 20:19:36 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-12-07 20:19:36 +0300
commitc1d3164700e76323e30cdf5c84af50c2ca46ff75 (patch)
tree355320f2a8897d99811b59dfecf6d28eb60eb99a
parenteb789de80379aacc987daceb937b2a80c94803ce (diff)
downloadrust-c1d3164700e76323e30cdf5c84af50c2ca46ff75.tar.gz
rust-c1d3164700e76323e30cdf5c84af50c2ca46ff75.zip
Add comments for Ident::from_name and identifiers in path segments
-rw-r--r--src/librustc_front/hir.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs
index dd4d7e28444..3f2bb87724d 100644
--- a/src/librustc_front/hir.rs
+++ b/src/librustc_front/hir.rs
@@ -63,6 +63,12 @@ pub struct Ident {
 }
 
 impl Ident {
+    /// Creates a HIR identifier with both `name` and `unhygienic_name` initialized with
+    /// the argument. Hygiene properties of the created identifier depend entirely on this
+    /// argument. If the argument is a plain interned string `intern("iter")`, then the result
+    /// is unhygienic and can interfere with other entities named "iter". If the argument is
+    /// a "fresh" name created with `gensym("iter")`, then the result is hygienic and can't
+    /// interfere with other entities having the same string as a name.
     pub fn from_name(name: Name) -> Ident {
         Ident { name: name, unhygienic_name: name }
     }
@@ -157,6 +163,14 @@ impl fmt::Display for Path {
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub struct PathSegment {
     /// The identifier portion of this path segment.
+    ///
+    /// Hygiene properties of this identifier are worth noting.
+    /// Most path segments are not hygienic and they are not renamed during
+    /// lowering from AST to HIR (see comments to `fn lower_path`). However segments from
+    /// unqualified paths with one segment originating from `ExprPath` (local-variable-like paths)
+    /// can be hygienic, so they are renamed. You should not normally care about this peculiarity
+    /// and just use `identifier.name` unless you modify identifier resolution code
+    /// (`fn resolve_identifier` and other functions called by it in `rustc_resolve`).
     pub identifier: Ident,
 
     /// Type/lifetime parameters attached to this path. They come in