about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-08-22 20:25:49 +0000
committerbors <bors@rust-lang.org>2014-08-22 20:25:49 +0000
commitd0104d04fdf5126bdc3f76eac93906f25a201ad3 (patch)
tree50f2f8051b74b8929dd5825214b31dcfcd9493a3 /src/libsyntax
parent58bb603ea74a388d7a4dafc0c78f214a46301505 (diff)
parentf59cfd9711e34d9152ea58409051985c362fc3ad (diff)
downloadrust-d0104d04fdf5126bdc3f76eac93906f25a201ad3.tar.gz
rust-d0104d04fdf5126bdc3f76eac93906f25a201ad3.zip
auto merge of #16659 : brson/rust/slowparse, r=alexcrichton
Note that this contains a 9.5MB test file, but it should compress thoroughly.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/mod.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index e76e4adcd7f..17a27a5a39e 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -412,14 +412,21 @@ pub fn str_lit(lit: &str) -> String {
     loop {
         match chars.next() {
             Some((i, c)) => {
-                let em = error(i);
                 match c {
                     '\\' => {
-                        if chars.peek().expect(em.as_slice()).val1() == '\n' {
+                        let ch = chars.peek().unwrap_or_else(|| {
+                            fail!("{}", error(i).as_slice())
+                        }).val1();
+
+                        if ch == '\n' {
                             eat(&mut chars);
-                        } else if chars.peek().expect(em.as_slice()).val1() == '\r' {
+                        } else if ch == '\r' {
                             chars.next();
-                            if chars.peek().expect(em.as_slice()).val1() != '\n' {
+                            let ch = chars.peek().unwrap_or_else(|| {
+                                fail!("{}", error(i).as_slice())
+                            }).val1();
+
+                            if ch != '\n' {
                                 fail!("lexer accepted bare CR");
                             }
                             eat(&mut chars);
@@ -433,7 +440,11 @@ pub fn str_lit(lit: &str) -> String {
                         }
                     },
                     '\r' => {
-                        if chars.peek().expect(em.as_slice()).val1() != '\n' {
+                        let ch = chars.peek().unwrap_or_else(|| {
+                            fail!("{}", error(i).as_slice())
+                        }).val1();
+
+                        if ch != '\n' {
                             fail!("lexer accepted bare CR");
                         }
                         chars.next();