diff options
| author | bors <bors@rust-lang.org> | 2014-10-29 20:16:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-29 20:16:57 +0000 |
| commit | 77f44d4a7bf14805fda5fc41310a6aeffda30fd4 (patch) | |
| tree | aea7012d4afbf278ae64ce92cff06c3d2a7e00cc /src/libsyntax/parse | |
| parent | 4769bca1483839ff9c0ad8353c206d6ee06c50e1 (diff) | |
| parent | 6ac7fc73f5acfe30c698ea4f8bfc37b30473977e (diff) | |
| download | rust-77f44d4a7bf14805fda5fc41310a6aeffda30fd4.tar.gz rust-77f44d4a7bf14805fda5fc41310a6aeffda30fd4.zip | |
auto merge of #17894 : steveklabnik/rust/fail_to_panic, r=aturon
This in-progress PR implements https://github.com/rust-lang/rust/issues/17489. I made the code changes in this commit, next is to go through alllllllll the documentation and fix various things. - Rename column headings as appropriate, `# Panics` for panic conditions and `# Errors` for `Result`s. - clean up usage of words like 'fail' in error messages Anything else to add to the list, @aturon ? I think I should leave the actual functions with names like `slice_or_fail` alone, since you'll get to those in your conventions work? I'm submitting just the code bits now so that we can see it separately, and I also don't want to have to keep re-building rust over and over again if I don't have to :wink: Listing all the bits so I can remember as I go: - [x] compiler-rt - [x] compiletest - [x] doc - [x] driver - [x] etc - [x] grammar - [x] jemalloc - [x] liballoc - [x] libarena - [x] libbacktrace - [x] libcollections - [x] libcore - [x] libcoretest - [x] libdebug - [x] libflate - [x] libfmt_macros - [x] libfourcc - [x] libgetopts - [x] libglob - [x] libgraphviz - [x] libgreen - [x] libhexfloat - [x] liblibc - [x] liblog - [x] libnative - [x] libnum - [x] librand - [x] librbml - [x] libregex - [x] libregex_macros - [x] librlibc - [x] librustc - [x] librustc_back - [x] librustc_llvm - [x] librustdoc - [x] librustrt - [x] libsemver - [x] libserialize - [x] libstd - [x] libsync - [x] libsyntax - [x] libterm - [x] libtest - [x] libtime - [x] libunicode - [x] liburl - [x] libuuid - [x] llvm - [x] rt - [x] test
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 32 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 |
4 files changed, 25 insertions, 25 deletions
diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 3814ecfbe5b..5a7679570bf 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -142,7 +142,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { return lines.connect("\n"); } - fail!("not a doc-comment: {}", comment); + panic!("not a doc-comment: {}", comment); } fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec<Comment>) { @@ -322,7 +322,7 @@ fn consume_comment(rdr: &mut StringReader, read_block_comment(rdr, code_to_the_left, comments); } else if rdr.curr_is('#') && rdr.nextch_is('!') { read_shebang_comment(rdr, code_to_the_left, comments); - } else { fail!(); } + } else { panic!(); } debug!("<<< consume comment"); } diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index b439353ad95..3a6cf610b4f 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -555,8 +555,8 @@ impl<'a> StringReader<'a> { whence: &str) { match r.curr { Some(r_c) if r_c == c => r.bump(), - Some(r_c) => fail!("expected {}, hit {}, {}", described_c, r_c, whence), - None => fail!("expected {}, hit EOF, {}", described_c, whence), + Some(r_c) => panic!("expected {}, hit {}, {}", described_c, r_c, whence), + None => panic!("expected {}, hit EOF, {}", described_c, whence), } } @@ -577,7 +577,7 @@ impl<'a> StringReader<'a> { self.scan_digits(base); let encoded_name : u32 = self.with_str_from(start_bpos, |s| { num::from_str_radix(s, 10).unwrap_or_else(|| { - fail!("expected digits representing a name, got `{}`, {}, range [{},{}]", + panic!("expected digits representing a name, got `{}`, {}, range [{},{}]", s, whence, start_bpos, self.last_pos); }) }); @@ -595,7 +595,7 @@ impl<'a> StringReader<'a> { self.scan_digits(base); let encoded_ctxt : ast::SyntaxContext = self.with_str_from(start_bpos, |s| { num::from_str_radix(s, 10).unwrap_or_else(|| { - fail!("expected digits representing a ctxt, got `{}`, {}", s, whence); + panic!("expected digits representing a ctxt, got `{}`, {}", s, whence); }) }); @@ -1542,7 +1542,7 @@ mod test { let mut lexer = setup(&sh, "/* /* */ */'a'".to_string()); match lexer.next_token().tok { token::Comment => { }, - _ => fail!("expected a comment!") + _ => panic!("expected a comment!") } assert_eq!(lexer.next_token().tok, token::LitChar(token::intern("a"))); } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index e60da0867f7..c731f3965a0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -65,7 +65,7 @@ impl ParseSess { match v.checked_add(&count) { Some(next) => { self.node_id.set(next); } - None => fail!("Input too large, ran out of node ids!") + None => panic!("Input too large, ran out of node ids!") } v @@ -381,7 +381,7 @@ pub fn char_lit(lit: &str) -> (char, int) { '0' => Some('\0'), _ => { None } }, - _ => fail!("lexer accepted invalid char escape `{}`", lit) + _ => panic!("lexer accepted invalid char escape `{}`", lit) }; match c { @@ -434,7 +434,7 @@ pub fn str_lit(lit: &str) -> String { match c { '\\' => { let ch = chars.peek().unwrap_or_else(|| { - fail!("{}", error(i).as_slice()) + panic!("{}", error(i).as_slice()) }).val1(); if ch == '\n' { @@ -442,11 +442,11 @@ pub fn str_lit(lit: &str) -> String { } else if ch == '\r' { chars.next(); let ch = chars.peek().unwrap_or_else(|| { - fail!("{}", error(i).as_slice()) + panic!("{}", error(i).as_slice()) }).val1(); if ch != '\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } eat(&mut chars); } else { @@ -460,11 +460,11 @@ pub fn str_lit(lit: &str) -> String { }, '\r' => { let ch = chars.peek().unwrap_or_else(|| { - fail!("{}", error(i).as_slice()) + panic!("{}", error(i).as_slice()) }).val1(); if ch != '\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } chars.next(); res.push('\n'); @@ -494,7 +494,7 @@ pub fn raw_str_lit(lit: &str) -> String { Some(c) => { if c == '\r' { if *chars.peek().unwrap() != '\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } chars.next(); res.push('\n'); @@ -553,11 +553,11 @@ pub fn byte_lit(lit: &str) -> (u8, uint) { match ::std::num::from_str_radix::<u64>(lit.slice(2, 4), 16) { Some(c) => if c > 0xFF { - fail!(err(2)) + panic!(err(2)) } else { return (c as u8, 4) }, - None => fail!(err(3)) + None => panic!(err(3)) } } }; @@ -594,7 +594,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> { b'\r' => { chars.next(); if chars.peek().expect(em.as_slice()).val1() != b'\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } eat(&mut chars); } @@ -612,7 +612,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> { Some((i, b'\r')) => { let em = error(i); if chars.peek().expect(em.as_slice()).val1() != b'\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } chars.next(); res.push(b'\n'); @@ -813,7 +813,7 @@ mod test { ast::TtToken(_, token::Ident(name, token::Plain))], &ast::Delimiter { token: token::RParen, .. }) if name.as_str() == "a" => {}, - _ => fail!("value 3: {}", **first_delimed), + _ => panic!("value 3: {}", **first_delimed), } let (ref second_open, ref second_tts, ref second_close) = **second_delimed; match (second_open, second_tts.as_slice(), second_close) { @@ -822,13 +822,13 @@ mod test { ast::TtToken(_, token::Ident(name, token::Plain))], &ast::Delimiter { token: token::RParen, .. }) if name.as_str() == "a" => {}, - _ => fail!("value 4: {}", **second_delimed), + _ => panic!("value 4: {}", **second_delimed), } }, - _ => fail!("value 2: {}", **macro_delimed), + _ => panic!("value 2: {}", **macro_delimed), } }, - _ => fail!("value: {}",tts), + _ => panic!("value: {}",tts), } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 654de709566..8ef3a559bf4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5746,7 +5746,7 @@ impl<'a> Parser<'a> { break; } IoviForeignItem(_) => { - fail!(); + panic!(); } } attrs = self.parse_outer_attributes(); @@ -5769,7 +5769,7 @@ impl<'a> Parser<'a> { items.push(item) } IoviForeignItem(_) => { - fail!(); + panic!(); } } } |
