about summary refs log tree commit diff
path: root/src/libregex
diff options
context:
space:
mode:
Diffstat (limited to 'src/libregex')
-rw-r--r--src/libregex/lib.rs1
-rw-r--r--src/libregex/parse.rs26
-rw-r--r--src/libregex/re.rs11
3 files changed, 23 insertions, 15 deletions
diff --git a/src/libregex/lib.rs b/src/libregex/lib.rs
index 0084be49b56..92ed048bae0 100644
--- a/src/libregex/lib.rs
+++ b/src/libregex/lib.rs
@@ -13,7 +13,6 @@
 //! Regular expressions implemented in Rust
 //!
 //! For official documentation, see the rust-lang/regex crate
-
 #![crate_name = "regex"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
diff --git a/src/libregex/parse.rs b/src/libregex/parse.rs
index 2d46fa1143e..dd11d42b8aa 100644
--- a/src/libregex/parse.rs
+++ b/src/libregex/parse.rs
@@ -40,7 +40,7 @@ pub struct Error {
 
 impl fmt::Show for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "Regex syntax error near position {}: {}",
+        write!(f, "Regex syntax error near position {}: {:?}",
                self.pos, self.msg)
     }
 }
@@ -122,7 +122,7 @@ impl BuildAst {
     fn flags(&self) -> Flags {
         match *self {
             Paren(flags, _, _) => flags,
-            _ => panic!("Cannot get flags from {}", self),
+            _ => panic!("Cannot get flags from {:?}", self),
         }
     }
 
@@ -130,7 +130,7 @@ impl BuildAst {
         match *self {
             Paren(_, 0, _) => None,
             Paren(_, c, _) => Some(c),
-            _ => panic!("Cannot get capture group from {}", self),
+            _ => panic!("Cannot get capture group from {:?}", self),
         }
     }
 
@@ -144,7 +144,7 @@ impl BuildAst {
                     Some(name.clone())
                 }
             }
-            _ => panic!("Cannot get capture name from {}", self),
+            _ => panic!("Cannot get capture name from {:?}", self),
         }
     }
 
@@ -158,7 +158,7 @@ impl BuildAst {
     fn unwrap(self) -> Result<Ast, Error> {
         match self {
             Expr(x) => Ok(x),
-            _ => panic!("Tried to unwrap non-AST item: {}", self),
+            _ => panic!("Tried to unwrap non-AST item: {:?}", self),
         }
     }
 }
@@ -285,7 +285,7 @@ impl<'a> Parser<'a> {
         match self.next_char() {
             true => Ok(()),
             false => {
-                self.err(format!("Expected {} but got EOF.",
+                self.err(format!("Expected {:?} but got EOF.",
                                  expected).index(&FullRange))
             }
         }
@@ -294,10 +294,10 @@ impl<'a> Parser<'a> {
     fn expect(&mut self, expected: char) -> Result<(), Error> {
         match self.next_char() {
             true if self.cur() == expected => Ok(()),
-            true => self.err(format!("Expected '{}' but got '{}'.",
+            true => self.err(format!("Expected '{:?}' but got '{:?}'.",
                                      expected, self.cur()).index(&FullRange)),
             false => {
-                self.err(format!("Expected '{}' but got EOF.",
+                self.err(format!("Expected '{:?}' but got EOF.",
                                  expected).index(&FullRange))
             }
         }
@@ -395,7 +395,7 @@ impl<'a> Parser<'a> {
                             continue
                         }
                         Some(ast) =>
-                            panic!("Expected Class AST but got '{}'", ast),
+                            panic!("Expected Class AST but got '{:?}'", ast),
                         // Just drop down and try to add as a regular character.
                         None => {},
                     },
@@ -410,7 +410,7 @@ impl<'a> Parser<'a> {
                             return self.err(
                                 "\\A, \\z, \\b and \\B are not valid escape \
                                  sequences inside a character class."),
-                        ast => panic!("Unexpected AST item '{}'", ast),
+                        ast => panic!("Unexpected AST item '{:?}'", ast),
                     }
                 }
                 ']' if ranges.len() > 0 || alts.len() > 0 => {
@@ -443,7 +443,7 @@ impl<'a> Parser<'a> {
                     match try!(self.parse_escape()) {
                         Literal(c3, _) => c2 = c3, // allow literal escapes below
                         ast =>
-                            return self.err(format!("Expected a literal, but got {}.",
+                            return self.err(format!("Expected a literal, but got {:?}.",
                                                     ast).index(&FullRange)),
                     }
                 }
@@ -513,7 +513,7 @@ impl<'a> Parser<'a> {
                 None => {
                     return self.err(format!("No closing brace for counted \
                                              repetition starting at position \
-                                             {}.",
+                                             {:?}.",
                                             start).index(&FullRange))
                 }
             };
@@ -686,7 +686,7 @@ impl<'a> Parser<'a> {
         match num::from_str_radix::<u32>(s.index(&FullRange), 8) {
             Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
             None => {
-                self.err(format!("Could not parse '{}' as octal number.",
+                self.err(format!("Could not parse '{:?}' as octal number.",
                                  s).index(&FullRange))
             }
         }
diff --git a/src/libregex/re.rs b/src/libregex/re.rs
index cb2690ce80c..37f9869f3bf 100644
--- a/src/libregex/re.rs
+++ b/src/libregex/re.rs
@@ -90,10 +90,19 @@ impl Clone for ExNative {
     }
 }
 
+#[cfg(stage0)]
+//FIXME: remove after stage0 snapshot
 impl fmt::Show for Regex {
     /// Shows the original regular expression.
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", self.as_str())
+        fmt::String::fmt(self.as_str(), f)
+    }
+}
+
+impl fmt::String for Regex {
+    /// Shows the original regular expression.
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self.as_str(), f)
     }
 }