diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-06 13:58:02 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-07 22:37:57 -0800 |
| commit | d7e74b5e91b0b6b6a5613f54479d2ef9fe9c392f (patch) | |
| tree | b1ce2f5b126be2790aad28ac0c0e526979d91e49 /src/libsyntax/parse | |
| parent | 0ea031bcb8c237365b8bf15ae474972570cf15f9 (diff) | |
| download | rust-d7e74b5e91b0b6b6a5613f54479d2ef9fe9c392f.tar.gz rust-d7e74b5e91b0b6b6a5613f54479d2ef9fe9c392f.zip | |
librustc: Convert all uses of `assert` over to `fail_unless!`
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
4 files changed, 15 insertions, 15 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index ca5c4564dd9..494ef3a81a0 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -57,7 +57,7 @@ pub fn is_doc_comment(s: &str) -> bool { } pub fn doc_comment_style(comment: &str) -> ast::attr_style { - assert is_doc_comment(comment); + fail_unless!(is_doc_comment(comment)); if comment.starts_with(~"//!") || comment.starts_with(~"/*!") { ast::attr_inner } else { @@ -136,8 +136,8 @@ fn read_to_eol(rdr: @mut StringReader) -> ~str { fn read_one_line_comment(rdr: @mut StringReader) -> ~str { let val = read_to_eol(rdr); - assert ((val[0] == '/' as u8 && val[1] == '/' as u8) || - (val[0] == '#' as u8 && val[1] == '!' as u8)); + fail_unless!((val[0] == '/' as u8 && val[1] == '/' as u8) || + (val[0] == '#' as u8 && val[1] == '!' as u8)); return val; } @@ -249,7 +249,7 @@ fn read_block_comment(rdr: @mut StringReader, bump(rdr); } if !is_block_non_doc_comment(curr_line) { return; } - assert !curr_line.contains_char('\n'); + fail_unless!(!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 524f9b48dd5..ab57d177112 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() { - assert rdr.curr != -1 as char; + fail_unless!(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 pure fn is_block_non_doc_comment(s: &str) -> bool { - assert s.len() >= 1u; + fail_unless!(s.len() >= 1u); str::all_between(s, 1u, s.len() - 1u, |ch| ch == '*') } @@ -872,21 +872,21 @@ pub mod test { let env = setup(~"'a'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert tok == token::LIT_INT('a' as i64, ast::ty_char); + fail_unless!(tok == token::LIT_INT('a' as i64, ast::ty_char)); } #[test] fn character_space() { let env = setup(~"' '"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert tok == token::LIT_INT(' ' as i64, ast::ty_char); + fail_unless!(tok == token::LIT_INT(' ' as i64, ast::ty_char)); } #[test] fn character_escaped() { let env = setup(~"'\n'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert tok == token::LIT_INT('\n' as i64, ast::ty_char); + fail_unless!(tok == token::LIT_INT('\n' as i64, ast::ty_char)); } #[test] fn lifetime_name() { @@ -894,7 +894,7 @@ pub mod test { let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); let id = env.interner.intern(@~"abc"); - assert tok == token::LIFETIME(id); + fail_unless!(tok == token::LIFETIME(id)); } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 96a8f780934..48d3fbe8889 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -197,7 +197,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 - assert rv != 0; + fail_unless!(rv != 0); return rv; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2a113c44612..0dba2bd45e1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2499,7 +2499,7 @@ pub impl Parser { fn parse_block(&self) -> blk { let (attrs, blk) = self.parse_inner_attrs_and_block(false); - assert vec::is_empty(attrs); + fail_unless!(vec::is_empty(attrs)); return blk; } @@ -3846,7 +3846,7 @@ pub impl Parser { foreign_items_allowed: bool, macros_allowed: bool ) -> item_or_view_item { - assert items_allowed != foreign_items_allowed; + fail_unless!(items_allowed != foreign_items_allowed); maybe_whole!(iovi self, nt_item); let lo = self.span.lo; @@ -4215,11 +4215,11 @@ pub impl Parser { view_items.push(view_item); } iovi_item(item) => { - assert items_allowed; + fail_unless!(items_allowed); items.push(item) } iovi_foreign_item(foreign_item) => { - assert foreign_items_allowed; + fail_unless!(foreign_items_allowed); foreign_items.push(foreign_item); } } |
