]> git.lizzy.rs Git - rust.git/commitdiff
Fix some violations of stronger guarantees for mutable borrows.
authorSimon Sapin <simon.sapin@exyr.org>
Tue, 17 Jun 2014 22:06:26 +0000 (00:06 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Tue, 17 Jun 2014 22:15:24 +0000 (00:15 +0200)
See 159e27aebb940926ccf1bad0b2b12087d36ad903

src/libsyntax/parse/lexer/mod.rs

index f67b77d64dda5d841ae52599dc0056591fd17d30..9039f346edb522cf4180b850534cc8bb211f495e 100644 (file)
@@ -906,8 +906,9 @@ fn parse_byte(self_: &mut StringReader) -> token::Token {
                     // Byte offsetting here is okay because the
                     // character before position `start` are an
                     // ascii single quote and ascii 'b'.
+                    let last_pos = self_.last_pos;
                     self_.fatal_span_verbose(
-                        start - BytePos(2), self_.last_pos,
+                        start - BytePos(2), last_pos,
                         "unterminated byte constant".to_string());
                 }
                 self_.bump(); // advance curr past token
@@ -920,7 +921,8 @@ fn parse_byte_string(self_: &mut StringReader) -> token::Token {
                 let mut value = Vec::new();
                 while !self_.curr_is('"') {
                     if self_.is_eof() {
-                        self_.fatal_span(start, self_.last_pos,
+                        let last_pos = self_.last_pos;
+                        self_.fatal_span(start, last_pos,
                                          "unterminated double quote byte string");
                     }
 
@@ -944,20 +946,25 @@ fn parse_raw_byte_string(self_: &mut StringReader) -> token::Token {
                 }
 
                 if self_.is_eof() {
-                    self_.fatal_span(start_bpos, self_.last_pos, "unterminated raw string");
+                    let last_pos = self_.last_pos;
+                    self_.fatal_span(start_bpos, last_pos, "unterminated raw string");
                 } else if !self_.curr_is('"') {
-                    self_.fatal_span_char(start_bpos, self_.last_pos,
+                    let last_pos = self_.last_pos;
+                    let ch = self_.curr.unwrap();
+                    self_.fatal_span_char(start_bpos, last_pos,
                                     "only `#` is allowed in raw string delimitation; \
                                      found illegal character",
-                                    self_.curr.unwrap());
+                                    ch);
                 }
                 self_.bump();
                 let content_start_bpos = self_.last_pos;
                 let mut content_end_bpos;
                 'outer: loop {
                     match self_.curr {
-                        None => self_.fatal_span(start_bpos, self_.last_pos,
-                                                 "unterminated raw string"),
+                        None => {
+                            let last_pos = self_.last_pos;
+                            self_.fatal_span(start_bpos, last_pos, "unterminated raw string")
+                        },
                         Some('"') => {
                             content_end_bpos = self_.last_pos;
                             for _ in range(0, hash_count) {
@@ -969,8 +976,9 @@ fn parse_raw_byte_string(self_: &mut StringReader) -> token::Token {
                             break;
                         },
                         Some(c) => if c > '\x7F' {
-                            self_.err_span_char(self_.last_pos, self_.last_pos,
-                                                "raw byte string must be ASCII", c);
+                            let last_pos = self_.last_pos;
+                            self_.err_span_char(
+                                last_pos, last_pos, "raw byte string must be ASCII", c);
                         }
                     }
                     self_.bump();