diff options
| author | bors <bors@rust-lang.org> | 2013-03-29 16:42:43 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-29 16:42:43 -0700 |
| commit | f864934f548be9f03d2c0512de8d7e908469e2ae (patch) | |
| tree | 8199ebdfbabc8b0a537f7b9330716e3b9c71714a /src/libsyntax | |
| parent | a17a9d41f6bf06daacb0aedb0cb2144dc4ba1c53 (diff) | |
| parent | 1e91595520d0538e6003dc9186f1b0df5c25b77a (diff) | |
| download | rust-f864934f548be9f03d2c0512de8d7e908469e2ae.tar.gz rust-f864934f548be9f03d2c0512de8d7e908469e2ae.zip | |
auto merge of #5628 : brson/rust/assert, r=brson
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/print/pp.rs | 20 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 8 |
10 files changed, 33 insertions, 46 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index b086670956e..7a8aff121a8 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -246,7 +246,7 @@ pub impl FileMap { fn next_line(&self, +pos: BytePos) { // the new charpos must be > the last one (or it's the first one). let lines = &mut *self.lines; - fail_unless!((lines.len() == 0) || (lines[lines.len() - 1] < pos)); + assert!((lines.len() == 0) || (lines[lines.len() - 1] < pos)); self.lines.push(pos); } @@ -264,7 +264,7 @@ pub impl FileMap { } pub fn record_multibyte_char(&self, pos: BytePos, bytes: uint) { - fail_unless!(bytes >=2 && bytes <= 4); + assert!(bytes >=2 && bytes <= 4); let mbc = MultiByteChar { pos: pos, bytes: bytes, @@ -387,7 +387,7 @@ pub impl CodeMap { pub fn span_to_snippet(&self, sp: span) -> ~str { let begin = self.lookup_byte_offset(sp.lo); let end = self.lookup_byte_offset(sp.hi); - fail_unless!(begin.fm.start_pos == end.fm.start_pos); + assert!(begin.fm.start_pos == end.fm.start_pos); return str::slice(*begin.fm.src, begin.pos.to_uint(), end.pos.to_uint()).to_owned(); } @@ -449,7 +449,7 @@ priv impl CodeMap { debug!("codemap: char pos %? is on the line at char pos %?", chpos, linechpos); debug!("codemap: byte is on line: %?", line); - fail_unless!(chpos >= linechpos); + assert!(chpos >= linechpos); return Loc { file: f, line: line, @@ -488,7 +488,7 @@ priv impl CodeMap { total_extra_bytes += mbc.bytes; // We should never see a byte position in the middle of a // character - fail_unless!(bpos == mbc.pos + assert!(bpos == mbc.pos || bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes); } else { break; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 6f49fe02239..09498f09a29 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -449,19 +449,6 @@ pub fn core_macros() -> ~str { ) ) - macro_rules! fail_unless( - ($cond:expr) => { - if !$cond { - ::core::sys::fail_assert(stringify!($cond), file!(), line!()) - } - }; - ($cond:expr, $msg:expr) => { - if !$cond { - ::core::sys::fail_assert($msg, file!(), line!()) - } - } - ) - macro_rules! assert( ($cond:expr) => { if !$cond { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 99033b3b3cc..ca8a17dad67 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -54,7 +54,7 @@ impl gen_send for message { message(ref _id, span, ref tys, this, Some(ref next_state)) => { debug!("pipec: next state exists"); let next = this.proto.get_state(next_state.state); - fail_unless!(next_state.tys.len() == + assert!(next_state.tys.len() == next.generics.ty_params.len()); let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str())); let args_ast = vec::map2(arg_names, *tys, |n, t| cx.arg(*n, *t)); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e6619d6dcfa..f74fbbc3c03 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -407,7 +407,7 @@ pub fn parse( } } - fail_unless!(cur_eis.len() > 0u); + assert!(cur_eis.len() > 0u); } } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 0804951327a..f90ff21cdf0 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -48,7 +48,7 @@ pub fn is_doc_comment(s: &str) -> bool { } pub fn doc_comment_style(comment: &str) -> ast::attr_style { - fail_unless!(is_doc_comment(comment)); + assert!(is_doc_comment(comment)); if comment.starts_with(~"//!") || comment.starts_with(~"/*!") { ast::attr_inner } else { @@ -134,7 +134,7 @@ fn read_to_eol(rdr: @mut StringReader) -> ~str { fn read_one_line_comment(rdr: @mut StringReader) -> ~str { let val = read_to_eol(rdr); - fail_unless!((val[0] == '/' as u8 && val[1] == '/' as u8) || + assert!((val[0] == '/' as u8 && val[1] == '/' as u8) || (val[0] == '#' as u8 && val[1] == '!' as u8)); return val; } @@ -247,7 +247,7 @@ fn read_block_comment(rdr: @mut StringReader, bump(rdr); } if !is_block_non_doc_comment(curr_line) { return; } - fail_unless!(!curr_line.contains_char('\n')); + assert!(!curr_line.contains_char('\n')); lines.push(curr_line); } else { let mut level: int = 1; diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index ffd2a1d801c..17d6ba3ac93 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -187,7 +187,7 @@ pub fn bump(rdr: @mut StringReader) { rdr.last_pos = rdr.pos; let current_byte_offset = byte_offset(rdr).to_uint();; if current_byte_offset < (*rdr.src).len() { - fail_unless!(rdr.curr != -1 as char); + assert!(rdr.curr != -1 as char); let last_char = rdr.curr; let next = str::char_range_at(*rdr.src, current_byte_offset); let byte_offset_diff = next.next - current_byte_offset; @@ -314,7 +314,7 @@ fn consume_any_line_comment(rdr: @mut StringReader) } pub fn is_block_non_doc_comment(s: &str) -> bool { - fail_unless!(s.len() >= 1u); + assert!(s.len() >= 1u); str::all_between(s, 1u, s.len() - 1u, |ch| ch == '*') } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index cdb67129c35..22e659fa574 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -214,7 +214,7 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id { let rv = sess.next_id; sess.next_id += 1; // ID 0 is reserved for the crate and doesn't actually exist in the AST - fail_unless!(rv != 0); + assert!(rv != 0); return rv; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d93e5995d4f..ac0e42fc65d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2529,7 +2529,7 @@ pub impl Parser { fn parse_block(&self) -> blk { let (attrs, blk) = self.parse_inner_attrs_and_block(false); - fail_unless!(vec::is_empty(attrs)); + assert!(vec::is_empty(attrs)); return blk; } @@ -3922,7 +3922,7 @@ pub impl Parser { foreign_items_allowed: bool, macros_allowed: bool ) -> item_or_view_item { - fail_unless!(items_allowed != foreign_items_allowed); + assert!(items_allowed != foreign_items_allowed); maybe_whole!(iovi self, nt_item); let lo = self.span.lo; @@ -4333,13 +4333,13 @@ pub impl Parser { view_items.push(view_item); } iovi_item(item) => { - fail_unless!(items_allowed); + assert!(items_allowed); items.push(item); attrs = self.parse_outer_attributes(); break; } iovi_foreign_item(foreign_item) => { - fail_unless!(foreign_items_allowed); + assert!(foreign_items_allowed); foreign_items.push(foreign_item); attrs = self.parse_outer_attributes(); break; @@ -4364,11 +4364,11 @@ pub impl Parser { view_items.push(view_item); } iovi_item(item) => { - fail_unless!(items_allowed); + assert!(items_allowed); items.push(item) } iovi_foreign_item(foreign_item) => { - fail_unless!(foreign_items_allowed); + assert!(foreign_items_allowed); foreign_items.push(foreign_item); } } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index af9cb7b841e..e742bdc056a 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -117,7 +117,7 @@ pub fn tok_str(++t: token) -> ~str { pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint, lim: uint) -> ~str { let n = vec::len(toks); - fail_unless!(n == vec::len(szs)); + assert!(n == vec::len(szs)); let mut i = left; let mut L = lim; let mut s = ~"["; @@ -369,12 +369,12 @@ pub impl Printer { } else { self.top += 1u; self.top %= self.buf_len; - fail_unless!((self.top != self.bottom)); + assert!((self.top != self.bottom)); } self.scan_stack[self.top] = x; } fn scan_pop(&mut self) -> uint { - fail_unless!((!self.scan_stack_empty)); + assert!((!self.scan_stack_empty)); let x = self.scan_stack[self.top]; if self.top == self.bottom { self.scan_stack_empty = true; @@ -382,11 +382,11 @@ pub impl Printer { return x; } fn scan_top(&mut self) -> uint { - fail_unless!((!self.scan_stack_empty)); + assert!((!self.scan_stack_empty)); return self.scan_stack[self.top]; } fn scan_pop_bottom(&mut self) -> uint { - fail_unless!((!self.scan_stack_empty)); + assert!((!self.scan_stack_empty)); let x = self.scan_stack[self.bottom]; if self.top == self.bottom { self.scan_stack_empty = true; @@ -396,7 +396,7 @@ pub impl Printer { fn advance_right(&mut self) { self.right += 1u; self.right %= self.buf_len; - fail_unless!((self.right != self.left)); + assert!((self.right != self.left)); } fn advance_left(&mut self, ++x: token, L: int) { debug!("advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right, @@ -406,7 +406,7 @@ pub impl Printer { match x { BREAK(b) => self.left_total += b.blank_space, STRING(_, len) => { - fail_unless!((len == L)); self.left_total += len; + assert!((len == L)); self.left_total += len; } _ => () } @@ -498,7 +498,7 @@ pub impl Printer { END => { debug!("print END -> pop END"); let print_stack = &*self.print_stack; - fail_unless!((print_stack.len() != 0u)); + assert!((print_stack.len() != 0u)); self.print_stack.pop(); } BREAK(b) => { @@ -532,8 +532,8 @@ pub impl Printer { } STRING(s, len) => { debug!("print STRING(%s)", *s); - fail_unless!((L == len)); - // fail_unless!(L <= space); + assert!((L == len)); + // assert!(L <= space); self.space -= len; self.print_str(*s); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 66907471c98..7ca5fba4c81 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1294,8 +1294,8 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { print_fn_block_args(s, decl); space(s.s); // } - fail_unless!(body.node.stmts.is_empty()); - fail_unless!(body.node.expr.is_some()); + assert!(body.node.stmts.is_empty()); + assert!(body.node.expr.is_some()); // we extract the block, so as not to create another set of boxes match body.node.expr.get().node { ast::expr_block(ref blk) => { @@ -1445,7 +1445,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) { // if any are mut, all are mut if locs.any(|l| l.node.is_mutbl) { - fail_unless!(locs.all(|l| l.node.is_mutbl)); + assert!(locs.all(|l| l.node.is_mutbl)); word_nbsp(s, ~"mut"); } @@ -2080,7 +2080,7 @@ pub fn maybe_print_comment(s: @ps, pos: BytePos) { pub fn print_comment(s: @ps, cmnt: comments::cmnt) { match cmnt.style { comments::mixed => { - fail_unless!((vec::len(cmnt.lines) == 1u)); + assert!((vec::len(cmnt.lines) == 1u)); zerobreak(s.s); word(s.s, cmnt.lines[0]); zerobreak(s.s); |
