about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-23 00:25:42 +0000
committerbors <bors@rust-lang.org>2015-09-23 00:25:42 +0000
commitb2f379cdc23aec5c5d0d62acfcc5a4a18ebf0e30 (patch)
tree5c758f791c9591be310ef5b3197f9bdfe5654896 /src/libsyntax
parentad82e0ac180deef65b5757a6e4d7fa79aab5521a (diff)
parent0af8e4754632279bf0b6a7143274c5d817f2833d (diff)
downloadrust-b2f379cdc23aec5c5d0d62acfcc5a4a18ebf0e30.tar.gz
rust-b2f379cdc23aec5c5d0d62acfcc5a4a18ebf0e30.zip
Auto merge of #28535 - petrochenkov:name, r=nrc
Part of https://github.com/rust-lang/rust/issues/6993

This patch replaces `Ident`s with `Name`s in data structures of HIR and updates the dependent crates to compile and pass `make check`.
Some HIR structures still use `Ident`s, namely `PathSegment`, `PatIdent`, `ExprWhile`, `ExprLoop`, `ExprBreak` and `ExprAgain`,  they need them for resolve (but `PathSegment` is special, see https://github.com/rust-lang/rust/issues/6993#issuecomment-141256292).

r? @nrc 
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 5b04fc0e697..62eb6022d0c 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -151,8 +151,7 @@ pub const ILLEGAL_CTXT : SyntaxContext = 1;
 
 /// A name is a part of an identifier, representing a string or gensym. It's
 /// the result of interning.
-#[derive(Eq, Ord, PartialEq, PartialOrd, Hash,
-           RustcEncodable, RustcDecodable, Clone, Copy)]
+#[derive(Eq, Ord, PartialEq, PartialOrd, Hash, Clone, Copy)]
 pub struct Name(pub u32);
 
 impl<T: AsRef<str>> PartialEq<T> for Name {
@@ -179,6 +178,18 @@ impl Name {
 /// A mark represents a unique id associated with a macro expansion
 pub type Mrk = u32;
 
+impl Encodable for Name {
+    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
+        s.emit_str(&self.as_str())
+    }
+}
+
+impl Decodable for Name {
+    fn decode<D: Decoder>(d: &mut D) -> Result<Name, D::Error> {
+        Ok(token::intern(&try!(d.read_str())[..]))
+    }
+}
+
 impl Encodable for Ident {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
         s.emit_str(&self.name.as_str())