Skip to content

Commit d19294f

Browse files
committed
Add new literal type Err
1 parent e2f221c commit d19294f

File tree

5 files changed

+6
-0
lines changed

5 files changed

+6
-0
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>(
329329
match *lit {
330330
token::Lit::Byte(val) |
331331
token::Lit::Char(val) |
332+
token::Lit::Err(val) |
332333
token::Lit::Integer(val) |
333334
token::Lit::Float(val) |
334335
token::Lit::Str_(val) |

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
646646

647647
token::Literal(token::Byte(i), suf) => return mk_lit!("Byte", suf, i),
648648
token::Literal(token::Char(i), suf) => return mk_lit!("Char", suf, i),
649+
token::Literal(token::Err(i), suf) => return mk_lit!("Err", suf, i),
649650
token::Literal(token::Integer(i), suf) => return mk_lit!("Integer", suf, i),
650651
token::Literal(token::Float(i), suf) => return mk_lit!("Float", suf, i),
651652
token::Literal(token::Str_(i), suf) => return mk_lit!("Str_", suf, i),

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ crate fn lit_token(lit: token::Lit, suf: Option<Symbol>, diag: Option<(Span, &Ha
466466
match lit {
467467
token::Byte(i) => (true, Some(LitKind::Byte(byte_lit(&i.as_str()).0))),
468468
token::Char(i) => (true, Some(LitKind::Char(char_lit(&i.as_str(), diag).0))),
469+
token::Err(i) => (true, Some(LitKind::Char(char_lit(&i.as_str(), diag).0))),
469470

470471
// There are some valid suffixes for integer and float literals,
471472
// so all the handling is done internally.

src/libsyntax/parse/token.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl DelimToken {
6060
pub enum Lit {
6161
Byte(ast::Name),
6262
Char(ast::Name),
63+
Err(ast::Name),
6364
Integer(ast::Name),
6465
Float(ast::Name),
6566
Str_(ast::Name),
@@ -73,6 +74,7 @@ impl Lit {
7374
match *self {
7475
Byte(_) => "byte literal",
7576
Char(_) => "char literal",
77+
Err(_) => "error literal",
7678
Integer(_) => "integer literal",
7779
Float(_) => "float literal",
7880
Str_(_) | StrRaw(..) => "string literal",

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub fn token_to_string(tok: &Token) -> String {
224224
let mut out = match lit {
225225
token::Byte(b) => format!("b'{}'", b),
226226
token::Char(c) => format!("'{}'", c),
227+
token::Err(c) => format!("'{}'", c),
227228
token::Float(c) |
228229
token::Integer(c) => c.to_string(),
229230
token::Str_(s) => format!("\"{}\"", s),

0 commit comments

Comments
 (0)