]> git.lizzy.rs Git - rust.git/commitdiff
[WIP] Improve error behavior
authorYuki Okushi <huyuumi.dev@gmail.com>
Sat, 19 Jan 2019 19:37:29 +0000 (04:37 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Sat, 19 Jan 2019 19:37:29 +0000 (04:37 +0900)
src/libsyntax/parse/lexer/mod.rs

index 2bf7ff4bd7a289276d72867ec851c106f3b2549c..fcaa35d1fca73456f88071c4f3d4baabeb9ad7f7 100644 (file)
@@ -1408,9 +1408,10 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                     // lifetimes shouldn't end with a single quote
                     // if we find one, then this is an invalid character literal
                     if self.ch_is('\'') {
-                        self.fatal_span_verbose(start_with_quote, self.next_pos,
-                                String::from("character literal may only contain one codepoint"))
-                            .raise();
+                        self.err_span_(start_with_quote, self.next_pos,
+                                "character literal may only contain one codepoint");
+                        self.bump();
+                        return Ok(token::Literal(token::Err(Symbol::intern("??")), None))
 
                     }
 
@@ -1445,7 +1446,7 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                                     format!("\"{}\"", &self.src[start..end]),
                                     Applicability::MachineApplicable
                                 ).emit();
-                            return Ok(token::Literal(token::Char(Symbol::intern("??")), None))
+                            return Ok(token::Literal(token::Err(Symbol::intern("??")), None))
                         }
                         if self.ch_is('\n') || self.is_eof() || self.ch_is('/') {
                             // Only attempt to infer single line string literals. If we encounter
@@ -1455,8 +1456,9 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                         }
                     }
 
-                    self.fatal_span_verbose(start_with_quote, pos,
-                        String::from("character literal may only contain one codepoint")).raise();
+                    self.err_span_(start_with_quote, pos,
+                        "character literal may only contain one codepoint");
+                    self.bump();
                 }
 
                 let id = if valid {