about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@mozilla.com>2013-01-31 17:51:01 -0800
committerBrian Anderson <banderson@mozilla.com>2013-01-31 20:12:49 -0800
commitaee79294699153ac7da9d2e5d076192c6eee3238 (patch)
tree18e14a0fcfddad87b2a2955e7821bb4c63acbbfa /src/libsyntax
parent2db3175c76b51e5124cfa135de7ceeea8ceee0d6 (diff)
downloadrust-aee79294699153ac7da9d2e5d076192c6eee3238.tar.gz
rust-aee79294699153ac7da9d2e5d076192c6eee3238.zip
Replace most invocations of fail keyword with die! macro
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs4
-rw-r--r--src/libsyntax/ast_map.rs4
-rw-r--r--src/libsyntax/ast_util.rs6
-rw-r--r--src/libsyntax/attr.rs2
-rw-r--r--src/libsyntax/codemap.rs6
-rw-r--r--src/libsyntax/diagnostic.rs4
-rw-r--r--src/libsyntax/ext/auto_encode.rs12
-rw-r--r--src/libsyntax/ext/pipes/parse_proto.rs4
-rw-r--r--src/libsyntax/ext/quote.rs8
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs6
-rw-r--r--src/libsyntax/parse/comments.rs4
-rw-r--r--src/libsyntax/parse/lexer.rs2
-rw-r--r--src/libsyntax/parse/parser.rs4
-rw-r--r--src/libsyntax/parse/token.rs4
-rw-r--r--src/libsyntax/print/pp.rs2
-rw-r--r--src/libsyntax/print/pprust.rs16
16 files changed, 44 insertions, 44 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index e85f41c54a2..7c947852afd 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -40,7 +40,7 @@ pub impl<S: Encoder> ident: Encodable<S> {
         let intr = match unsafe {
             task::local_data::local_data_get(interner_key!())
         } {
-            None => fail ~"encode: TLS interner not set up",
+            None => die!(~"encode: TLS interner not set up"),
             Some(intr) => intr
         };
 
@@ -53,7 +53,7 @@ pub impl<D: Decoder> ident: Decodable<D> {
         let intr = match unsafe {
             task::local_data::local_data_get(interner_key!())
         } {
-            None => fail ~"decode: TLS interner not set up",
+            None => die!(~"decode: TLS interner not set up"),
             Some(intr) => intr
         };
 
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index a96829ed063..759d3d2d824 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -316,7 +316,7 @@ pub fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
                     cx.map.insert(ctor_id,
                                   node_struct_ctor(struct_def, item, p));
                 }
-                _ => fail ~"struct def parent wasn't an item"
+                _ => die!(~"struct def parent wasn't an item")
             }
         }
     }
@@ -400,7 +400,7 @@ pub fn node_item_query<Result>(items: map, id: node_id,
                            error_msg: ~str) -> Result {
     match items.find(id) {
         Some(node_item(it, _)) => query(it),
-        _ => fail(error_msg)
+        _ => die!(error_msg)
     }
 }
 
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 1ae23240404..bdea3d6d6f3 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -66,7 +66,7 @@ pub pure 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(*) => die!(~"attempted to analyze unexpanded stmt")
     }
 }
 
@@ -75,7 +75,7 @@ pub fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} {
       def_variant(enum_id, var_id) => {
         return {enm: enum_id, var: var_id}
       }
-      _ => fail ~"non-variant in variant_def_ids"
+      _ => die!(~"non-variant in variant_def_ids")
     }
 }
 
@@ -93,7 +93,7 @@ pub pure fn def_id_of_def(d: def) -> def_id {
         local_def(id)
       }
 
-      def_prim_ty(_) => fail
+      def_prim_ty(_) => die!()
     }
 }
 
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index dd6a996b730..d9b22248b14 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -199,7 +199,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
             // FIXME (#607): Needs implementing
             // This involves probably sorting the list by name and
             // meta_item variant
-            fail ~"unimplemented meta_item variant"
+            die!(~"unimplemented meta_item variant")
           }
         }
 }
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 980d4a236e0..b51327a0dfb 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -356,7 +356,7 @@ pub impl CodeMap {
         for self.files.each |fm| { if fm.name == filename { return *fm; } }
         //XXjdm the following triggers a mismatched type bug
         //      (or expected function, found _|_)
-        fail; // ("asking for " + filename + " which we don't know about");
+        die!(); // ("asking for " + filename + " which we don't know about");
     }
 
 }
@@ -376,8 +376,8 @@ priv impl CodeMap {
             }
         }
         if (a >= len) {
-            fail fmt!("position %u does not resolve to a source location",
-                      pos.to_uint())
+            die!(fmt!("position %u does not resolve to a source location",
+                      pos.to_uint()))
         }
 
         return a;
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index d2f6b7956ef..c454f5dde2b 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -63,7 +63,7 @@ struct codemap_t {
 impl codemap_t: span_handler {
     fn span_fatal(sp: span, msg: &str) -> ! {
         self.handler.emit(Some((self.cm, sp)), msg, fatal);
-        fail;
+        die!();
     }
     fn span_err(sp: span, msg: &str) {
         self.handler.emit(Some((self.cm, sp)), msg, error);
@@ -89,7 +89,7 @@ impl codemap_t: span_handler {
 impl handler_t: handler {
     fn fatal(msg: &str) -> ! {
         (self.emit)(None, msg, fatal);
-        fail;
+        die!();
     }
     fn err(msg: &str) {
         (self.emit)(None, msg, error);
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index a2484e2d6df..e406e09aac0 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -812,8 +812,8 @@ fn mk_struct_fields(fields: ~[@ast::struct_field]) -> ~[field] {
     do fields.map |field| {
         let (ident, mutbl) = match field.node.kind {
             ast::named_field(ident, mutbl, _) => (ident, mutbl),
-            _ => fail ~"[auto_encode] does not support \
-                        unnamed fields",
+            _ => die!(~"[auto_encode] does not support \
+                        unnamed fields")
         };
 
         field {
@@ -954,9 +954,9 @@ fn mk_enum_ser_body(
             ast::tuple_variant_kind(args) =>
                 ser_variant(cx, span, variant.node.name, v_idx, args),
             ast::struct_variant_kind(*) =>
-                fail ~"struct variants unimplemented",
+                die!(~"struct variants unimplemented"),
             ast::enum_variant_kind(*) =>
-                fail ~"enum variants unimplemented",
+                die!(~"enum variants unimplemented"),
         }
     };
 
@@ -1047,9 +1047,9 @@ fn mk_enum_deser_body(
                 }
             },
             ast::struct_variant_kind(*) =>
-                fail ~"struct variants unimplemented",
+                die!(~"struct variants unimplemented"),
             ast::enum_variant_kind(*) =>
-                fail ~"enum variants unimplemented",
+                die!(~"enum variants unimplemented")
         };
 
         let pat = @ast::pat {
diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs
index a74214c8758..1502332859c 100644
--- a/src/libsyntax/ext/pipes/parse_proto.rs
+++ b/src/libsyntax/ext/pipes/parse_proto.rs
@@ -40,13 +40,13 @@ pub impl parser::Parser: proto_parser {
         self.expect(token::COLON);
         let dir = match copy self.token {
           token::IDENT(n, _) => self.interner.get(n),
-          _ => fail
+          _ => die!()
         };
         self.bump();
         let dir = match dir {
           @~"send" => send,
           @~"recv" => recv,
-          _ => fail
+          _ => die!()
         };
 
         let typarms = if self.token == token::LT {
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 7605e01fbf0..4a9a22de50f 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -184,7 +184,7 @@ pub mod rt {
                 Some(ast) => ast,
                 None => {
                     error!("Parse error with ```\n%s\n```", s);
-                    fail
+                    die!()
                 }
             }
         }
@@ -399,7 +399,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(_) => die!(~"quote! with interpolated token"),
 
         _ => ()
     }
@@ -437,7 +437,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr {
         DOLLAR => "DOLLAR",
         UNDERSCORE => "UNDERSCORE",
         EOF => "EOF",
-        _ => fail
+        _ => die!()
     };
     build::mk_path(cx, sp,
                    ids_ext(cx, ~[name.to_owned()]))
@@ -467,7 +467,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(*) => die!(~"tt_seq in quote!"),
 
         ast::tt_nonterminal(sp, ident) => {
 
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 4c0550b3c3a..1c7a12a4282 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -125,7 +125,7 @@ pub type matcher_pos = ~{
 pub fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos {
     match &mpu {
       &matcher_pos_up(Some(ref mp)) => copy (*mp),
-      _ => fail
+      _ => die!()
     }
 }
 
@@ -362,7 +362,7 @@ pub fn parse(sess: parse_sess,
                         fmt!("%s ('%s')", *sess.interner.get(name),
                              *sess.interner.get(bind))
                       }
-                      _ => fail
+                      _ => die!()
                     } }), ~" or ");
                 return error(sp, fmt!(
                     "Local ambiguity: multiple parsing options: \
@@ -387,7 +387,7 @@ pub fn parse(sess: parse_sess,
                         parse_nt(rust_parser, *sess.interner.get(name))));
                     ei.idx += 1u;
                   }
-                  _ => fail
+                  _ => die!()
                 }
                 cur_eis.push(move ei);
 
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 26de85548e1..8ed10fb138d 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -117,7 +117,7 @@ pub fn strip_doc_comment_decoration(comment: ~str) -> ~str {
         return str::connect(lines, ~"\n");
     }
 
-    fail ~"not a doc-comment: " + comment;
+    die!(~"not a doc-comment: " + comment);
 }
 
 fn read_to_eol(rdr: string_reader) -> ~str {
@@ -295,7 +295,7 @@ fn consume_comment(rdr: string_reader, code_to_the_left: bool,
         read_block_comment(rdr, code_to_the_left, comments);
     } else if rdr.curr == '#' && nextch(rdr) == '!' {
         read_shebang_comment(rdr, code_to_the_left, comments);
-    } else { fail; }
+    } else { die!(); }
     debug!("<<< consume comment");
 }
 
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index c3b94182cc2..65fc86a106a 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -203,7 +203,7 @@ fn hex_digit_val(c: char) -> int {
     if in_range(c, '0', '9') { return (c as int) - ('0' as int); }
     if in_range(c, 'a', 'f') { return (c as int) - ('a' as int) + 10; }
     if in_range(c, 'A', 'F') { return (c as int) - ('A' as int) + 10; }
-    fail;
+    die!();
 }
 
 fn bin_digit_value(c: char) -> int { if c == '0' { return 0; } return 1; }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 48f38092f88..51acf76ac30 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2500,7 +2500,7 @@ pub impl Parser {
                           _ => None
                         }
                       }
-                      _ => fail
+                      _ => die!()
                     };
 
                     match maybe_bound {
@@ -3892,7 +3892,7 @@ pub impl Parser {
             let metadata = self.parse_optional_meta();
             view_item_use(ident, metadata, self.get_id())
         } else {
-            fail;
+            die!();
         };
         self.expect(token::SEMI);
         @ast::view_item { node: node,
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 2093b5caebd..bcf4281132d 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -209,7 +209,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(*) => die!(~"should have been handled above"),
                       nt_ty(*) => ~"type",
                       nt_ident(*) => ~"identifier",
                       nt_path(*) => ~"path",
@@ -262,7 +262,7 @@ pub fn flip_delimiter(t: token::Token) -> token::Token {
       token::RPAREN => token::LPAREN,
       token::RBRACE => token::LBRACE,
       token::RBRACKET => token::LBRACKET,
-      _ => fail
+      _ => die!()
     }
 }
 
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index d3487fa845f..0159a74ab88 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -532,7 +532,7 @@ pub impl printer {
           }
           EOF => {
             // EOF should never get here.
-            fail;
+            die!();
           }
         }
     }
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 6661f5e810a..72fd205fee9 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -422,10 +422,10 @@ pub fn print_type_ex(s: ps, &&ty: @ast::Ty, print_colons: bool) {
         word(s.s, ~"]");
       }
       ast::ty_mac(_) => {
-          fail ~"print_type doesn't know how to print a ty_mac";
+          die!(~"print_type doesn't know how to print a ty_mac");
       }
       ast::ty_infer => {
-          fail ~"print_type shouldn't see a ty_infer";
+          die!(~"print_type shouldn't see a ty_infer");
       }
 
     }
@@ -617,7 +617,7 @@ pub fn print_enum_def(s: ps, enum_definition: ast::enum_def,
         word_space(s, ~"=");
         match enum_definition.variants[0].node.kind {
             ast::tuple_variant_kind(args) => print_type(s, args[0].ty),
-            _ => fail ~"newtype syntax with struct?"
+            _ => die!(~"newtype syntax with struct?")
         }
         word(s.s, ~";");
         end(s);
@@ -686,7 +686,7 @@ pub fn print_struct(s: ps,
             }
 
             match field.node.kind {
-                ast::named_field(*) => fail ~"unexpected named field",
+                ast::named_field(*) => die!(~"unexpected named field"),
                 ast::unnamed_field => {
                     maybe_print_comment(s, field.span.lo);
                     print_type(s, field.node.ty);
@@ -709,7 +709,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 => die!(~"unexpected unnamed field"),
                 ast::named_field(ident, mutability, visibility) => {
                     hardbreak_if_not_bol(s);
                     maybe_print_comment(s, field.span.lo);
@@ -995,7 +995,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";
+                  die!(~"print_if saw if with weird alternative");
               }
             }
           }
@@ -1296,7 +1296,7 @@ pub fn print_expr(s: ps, &&expr: @ast::expr) {
                         }
                         end(s); // close enclosing cbox
                     }
-                    None => fail
+                    None => die!()
                 }
             } else {
                 // the block will close the pattern's ibox
@@ -2244,7 +2244,7 @@ pub mod test {
 
     fn string_check<T : Eq> (given : &T, expected: &T) {
         if !(given == expected) {
-            fail (fmt!("given %?, expected %?",given,expected));
+            die!(fmt!("given %?, expected %?",given,expected));
         }
     }