]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ast.rs
Change syntax::ast_util::stmt_id to not panic on macros
[rust.git] / src / libsyntax / ast.rs
index 7b2b2c9012608e34d1c51183d87dd31cdaa973c1..cdddaaffc357dfb66208018b58d80505a151de42 100644 (file)
@@ -10,7 +10,6 @@
 
 // The Rust abstract syntax tree.
 
-pub use self::AsmDialect::*;
 pub use self::AttrStyle::*;
 pub use self::BindingMode::*;
 pub use self::BinOp_::*;
@@ -66,6 +65,7 @@
 
 use std::fmt;
 use std::rc::Rc;
+use std::borrow::Cow;
 use serialize::{Encodable, Decodable, Encoder, Decoder};
 
 // FIXME #6993: in librustc, uses of "ident" should be replaced
@@ -686,7 +686,8 @@ pub enum UnOp {
 impl fmt::Debug for Stmt {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "stmt({}: {})",
-               ast_util::stmt_id(self),
+               ast_util::stmt_id(self)
+                   .map_or(Cow::Borrowed("<macro>"),|id|Cow::Owned(id.to_string())),
                pprust::stmt_to_string(self))
     }
 }
@@ -1440,8 +1441,8 @@ pub enum Ty_ {
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
 pub enum AsmDialect {
-    AsmAtt,
-    AsmIntel
+    Att,
+    Intel,
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]