about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2013-05-06 00:18:51 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2013-05-14 16:36:23 +0200
commitbdc182cc41c2741edc6fdc4ec09b8522479aab40 (patch)
treee4d26bbc1b47702ef46cd01bbaa5b5dad8633416 /src/libsyntax
parent84745b483f322671f894b9e8d0a462c46275a9d3 (diff)
downloadrust-bdc182cc41c2741edc6fdc4ec09b8522479aab40.tar.gz
rust-bdc182cc41c2741edc6fdc4ec09b8522479aab40.zip
Use static string with fail!() and remove fail!(fmt!())
fail!() used to require owned strings but can handle static strings
now. Also, it can pass its arguments to fmt!() on its own, no need for
the caller to call fmt!() itself.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/abi.rs4
-rw-r--r--src/libsyntax/ast.rs4
-rw-r--r--src/libsyntax/ast_map.rs2
-rw-r--r--src/libsyntax/ast_util.rs2
-rw-r--r--src/libsyntax/codemap.rs4
-rw-r--r--src/libsyntax/ext/auto_encode.rs6
-rw-r--r--src/libsyntax/ext/base.rs4
-rw-r--r--src/libsyntax/ext/expand.rs6
-rw-r--r--src/libsyntax/ext/quote.rs4
-rw-r--r--src/libsyntax/opt_vec.rs2
-rw-r--r--src/libsyntax/parse/comments.rs2
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/libsyntax/print/pprust.rs12
13 files changed, 27 insertions, 27 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs
index f266b8871a2..ee62bb270b8 100644
--- a/src/libsyntax/abi.rs
+++ b/src/libsyntax/abi.rs
@@ -338,7 +338,7 @@ fn cannot_combine(n: Abi, m: Abi) {
                          (m == a && n == b));
         }
         None => {
-            fail!(~"Invalid match not detected");
+            fail!("Invalid match not detected");
         }
     }
 }
@@ -350,7 +350,7 @@ fn can_combine(n: Abi, m: Abi) {
     set.add(m);
     match set.check_valid() {
         Some((_, _)) => {
-            fail!(~"Valid match declared invalid");
+            fail!("Valid match declared invalid");
         }
         None => {}
     }
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index f98cbe2e5b9..94bd9a18589 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -74,7 +74,7 @@ impl<S:Encoder> Encodable<S> for ident {
         unsafe {
             let intr =
                 match local_data::local_data_get(interner_key!()) {
-                    None => fail!(~"encode: TLS interner not set up"),
+                    None => fail!("encode: TLS interner not set up"),
                     Some(intr) => intr
                 };
 
@@ -88,7 +88,7 @@ impl<D:Decoder> Decodable<D> for ident {
         let intr = match unsafe {
             local_data::local_data_get(interner_key!())
         } {
-            None => fail!(~"decode: TLS interner not set up"),
+            None => fail!("decode: TLS interner not set up"),
             Some(intr) => intr
         };
 
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index 77a02adbafb..72e9a3d2cd0 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -304,7 +304,7 @@ pub fn map_struct_def(
                     cx.map.insert(ctor_id,
                                   node_struct_ctor(struct_def, item, p));
                 }
-                _ => fail!(~"struct def parent wasn't an item")
+                _ => fail!("struct def parent wasn't an item")
             }
         }
     }
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index ceff868d11f..0ea0dcf16f6 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -37,7 +37,7 @@ pub fn stmt_id(s: &stmt) -> node_id {
       stmt_decl(_, id) => id,
       stmt_expr(_, id) => id,
       stmt_semi(_, id) => id,
-      stmt_mac(*) => fail!(~"attempted to analyze unexpanded stmt")
+      stmt_mac(*) => fail!("attempted to analyze unexpanded stmt")
     }
 }
 
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 053ed76d66b..837ce58af1a 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -430,8 +430,8 @@ priv impl CodeMap {
             }
         }
         if (a >= len) {
-            fail!(fmt!("position %u does not resolve to a source location",
-                      pos.to_uint()))
+            fail!("position %u does not resolve to a source location",
+                      pos.to_uint())
         }
 
         return a;
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index e1416230720..9b78d9954d3 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -917,7 +917,7 @@ fn mk_struct_fields(fields: &[@ast::struct_field]) -> ~[field] {
     do fields.map |field| {
         let ident = match field.node.kind {
             ast::named_field(ident, _) => ident,
-            _ => fail!(~"[auto_encode] does not support unnamed fields")
+            _ => fail!("[auto_encode] does not support unnamed fields")
         };
 
         field {
@@ -1056,7 +1056,7 @@ fn mk_enum_ser_body(
                     /*bad*/ copy *args
                 ),
             ast::struct_variant_kind(*) =>
-                fail!(~"struct variants unimplemented"),
+                fail!("struct variants unimplemented"),
         }
     };
 
@@ -1151,7 +1151,7 @@ fn mk_enum_deser_body(
                 }
             },
             ast::struct_variant_kind(*) =>
-                fail!(~"struct variants unimplemented"),
+                fail!("struct variants unimplemented"),
         };
 
         let pat = @ast::pat {
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 95e858f6143..20bf01c0dc1 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -479,11 +479,11 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
     // names? I think not.
     // delaying implementing this....
     fn each_key (&self, _f: &fn (&K)->bool) {
-        fail!(~"unimplemented 2013-02-15T10:01");
+        fail!("unimplemented 2013-02-15T10:01");
     }
 
     fn each_value (&self, _f: &fn (&V) -> bool) {
-        fail!(~"unimplemented 2013-02-15T10:02");
+        fail!("unimplemented 2013-02-15T10:02");
     }
 
     // Returns a copy of the value that the name maps to.
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 0fe28dadbc7..914fc74c3d1 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -468,7 +468,7 @@ pub fn core_macros() -> ~str {
                 let expected_val = $expected;
                 // check both directions of equality....
                 if !((given_val == expected_val) && (expected_val == given_val)) {
-                    fail!(fmt!(\"left: %? != right: %?\", given_val, expected_val));
+                    fail!(\"left: %? != right: %?\", given_val, expected_val);
                 }
             }
         )
@@ -660,7 +660,7 @@ mod test {
 
     // make sure that fail! is present
     #[test] fn fail_exists_test () {
-        let src = ~"fn main() { fail!(~\"something appropriately gloomy\");}";
+        let src = ~"fn main() { fail!(\"something appropriately gloomy\");}";
         let sess = parse::new_parse_sess(None);
         let cfg = ~[];
         let crate_ast = parse::parse_crate_from_source_str(
@@ -733,7 +733,7 @@ mod test {
             cfg,~[make_dummy_attr (@~"macro_escape")],sess);
         match item_ast {
             Some(_) => (), // success
-            None => fail!(~"expected this to parse")
+            None => fail!("expected this to parse")
         }
     }
 
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 9344a49c9a9..d5b3adca168 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -556,7 +556,7 @@ fn mk_token(cx: @ext_ctxt, sp: span, tok: token::Token) -> @ast::expr {
                                   ~[mk_ident(cx, sp, ident)]);
         }
 
-        INTERPOLATED(_) => fail!(~"quote! with interpolated token"),
+        INTERPOLATED(_) => fail!("quote! with interpolated token"),
 
         _ => ()
     }
@@ -623,7 +623,7 @@ fn mk_tt(cx: @ext_ctxt, sp: span, tt: &ast::token_tree)
         }
 
         ast::tt_delim(ref tts) => mk_tts(cx, sp, *tts),
-        ast::tt_seq(*) => fail!(~"tt_seq in quote!"),
+        ast::tt_seq(*) => fail!("tt_seq in quote!"),
 
         ast::tt_nonterminal(sp, ident) => {
 
diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs
index 6110579863d..a98e93eec84 100644
--- a/src/libsyntax/opt_vec.rs
+++ b/src/libsyntax/opt_vec.rs
@@ -63,7 +63,7 @@ impl<T> OptVec<T> {
 
     fn get<'a>(&'a self, i: uint) -> &'a T {
         match *self {
-            Empty => fail!(fmt!("Invalid index %u", i)),
+            Empty => fail!("Invalid index %u", i),
             Vec(ref v) => &v[i]
         }
     }
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index acfd18c74de..8faba022a90 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -111,7 +111,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
         return str::connect(lines, ~"\n");
     }
 
-    fail!(~"not a doc-comment: " + comment);
+    fail!("not a doc-comment: %s", comment);
 }
 
 fn read_to_eol(rdr: @mut StringReader) -> ~str {
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index fde383b445c..27686c4e4aa 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -211,7 +211,7 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
                       nt_block(*) => ~"block",
                       nt_stmt(*) => ~"statement",
                       nt_pat(*) => ~"pattern",
-                      nt_expr(*) => fail!(~"should have been handled above"),
+                      nt_expr(*) => fail!("should have been handled above"),
                       nt_ty(*) => ~"type",
                       nt_ident(*) => ~"identifier",
                       nt_path(*) => ~"path",
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 2e7c35807e5..65e4cdb53ab 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -430,10 +430,10 @@ pub fn print_type(s: @ps, ty: @ast::Ty) {
         word(s.s, ~"]");
       }
       ast::ty_mac(_) => {
-          fail!(~"print_type doesn't know how to print a ty_mac");
+          fail!("print_type doesn't know how to print a ty_mac");
       }
       ast::ty_infer => {
-          fail!(~"print_type shouldn't see a ty_infer");
+          fail!("print_type shouldn't see a ty_infer");
       }
 
     }
@@ -683,7 +683,7 @@ pub fn print_struct(s: @ps,
             popen(s);
             do commasep(s, inconsistent, struct_def.fields) |s, field| {
                 match field.node.kind {
-                    ast::named_field(*) => fail!(~"unexpected named field"),
+                    ast::named_field(*) => fail!("unexpected named field"),
                     ast::unnamed_field => {
                         maybe_print_comment(s, field.span.lo);
                         print_type(s, field.node.ty);
@@ -702,7 +702,7 @@ pub fn print_struct(s: @ps,
 
         for struct_def.fields.each |field| {
             match field.node.kind {
-                ast::unnamed_field => fail!(~"unexpected unnamed field"),
+                ast::unnamed_field => fail!("unexpected unnamed field"),
                 ast::named_field(ident, visibility) => {
                     hardbreak_if_not_bol(s);
                     maybe_print_comment(s, field.span.lo);
@@ -984,7 +984,7 @@ pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk,
               }
               // BLEAH, constraints would be great here
               _ => {
-                  fail!(~"print_if saw if with weird alternative");
+                  fail!("print_if saw if with weird alternative");
               }
             }
           }
@@ -2237,7 +2237,7 @@ mod test {
 
     fn string_check<T:Eq> (given : &T, expected: &T) {
         if !(given == expected) {
-            fail!(fmt!("given %?, expected %?",given,expected));
+            fail!("given %?, expected %?",given,expected);
         }
     }