Skip to content

Commit c502a79

Browse files
committed
[WIP] Improve error behavior
1 parent b721c1a commit c502a79

File tree

1 file changed

+8
-6
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+8
-6
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,9 +1408,10 @@ impl<'a> StringReader<'a> {
14081408
// lifetimes shouldn't end with a single quote
14091409
// if we find one, then this is an invalid character literal
14101410
if self.ch_is('\'') {
1411-
self.fatal_span_verbose(start_with_quote, self.next_pos,
1412-
String::from("character literal may only contain one codepoint"))
1413-
.raise();
1411+
self.err_span_(start_with_quote, self.next_pos,
1412+
"character literal may only contain one codepoint");
1413+
self.bump();
1414+
return Ok(token::Literal(token::Err(Symbol::intern("??")), None))
14141415

14151416
}
14161417

@@ -1445,7 +1446,7 @@ impl<'a> StringReader<'a> {
14451446
format!("\"{}\"", &self.src[start..end]),
14461447
Applicability::MachineApplicable
14471448
).emit();
1448-
return Ok(token::Literal(token::Char(Symbol::intern("??")), None))
1449+
return Ok(token::Literal(token::Err(Symbol::intern("??")), None))
14491450
}
14501451
if self.ch_is('\n') || self.is_eof() || self.ch_is('/') {
14511452
// Only attempt to infer single line string literals. If we encounter
@@ -1455,8 +1456,9 @@ impl<'a> StringReader<'a> {
14551456
}
14561457
}
14571458

1458-
self.fatal_span_verbose(start_with_quote, pos,
1459-
String::from("character literal may only contain one codepoint")).raise();
1459+
self.err_span_(start_with_quote, pos,
1460+
"character literal may only contain one codepoint");
1461+
self.bump();
14601462
}
14611463

14621464
let id = if valid {

0 commit comments

Comments
 (0)