]> git.lizzy.rs Git - rust.git/commitdiff
Add new literal type Err
authorYuki Okushi <huyuumi.dev@gmail.com>
Wed, 16 Jan 2019 00:27:43 +0000 (09:27 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Wed, 16 Jan 2019 00:27:43 +0000 (09:27 +0900)
src/librustc/ich/impls_syntax.rs
src/libsyntax/ext/quote.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pprust.rs

index 70ec72d73bc6cc9a83f8c15ecf2e8c4a26239641..6ffb771ffcc4e837a5c4b7e75f9b41c9adcf33de 100644 (file)
@@ -329,6 +329,7 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>(
             match *lit {
                 token::Lit::Byte(val) |
                 token::Lit::Char(val) |
+                token::Lit::Err(val) |
                 token::Lit::Integer(val) |
                 token::Lit::Float(val) |
                 token::Lit::Str_(val) |
index c3124144009ab61bfc2b7f589d8df50e59d3586c..17c88a30bcd0b2d1853a17c0500416796fecc934 100644 (file)
@@ -646,6 +646,7 @@ macro_rules! mk_lit {
 
         token::Literal(token::Byte(i), suf) => return mk_lit!("Byte", suf, i),
         token::Literal(token::Char(i), suf) => return mk_lit!("Char", suf, i),
+        token::Literal(token::Err(i), suf) => return mk_lit!("Err", suf, i),
         token::Literal(token::Integer(i), suf) => return mk_lit!("Integer", suf, i),
         token::Literal(token::Float(i), suf) => return mk_lit!("Float", suf, i),
         token::Literal(token::Str_(i), suf) => return mk_lit!("Str_", suf, i),
index ea205530ca5ccb2dfdc8c35752203cd5e26cfcbb..cbb503f56bc4ad31829b8d3abfecfbb109f704bf 100644 (file)
@@ -466,6 +466,7 @@ macro_rules! err {
     match lit {
        token::Byte(i) => (true, Some(LitKind::Byte(byte_lit(&i.as_str()).0))),
        token::Char(i) => (true, Some(LitKind::Char(char_lit(&i.as_str(), diag).0))),
+       token::Err(i) => (true, Some(LitKind::Char(char_lit(&i.as_str(), diag).0))),
 
         // There are some valid suffixes for integer and float literals,
         // so all the handling is done internally.
index 25a4da38c8c511863b557d97456ea0f92b97a676..69e934d64c6cde15edc121653434dd9c417f011b 100644 (file)
@@ -60,6 +60,7 @@ pub fn is_empty(self) -> bool {
 pub enum Lit {
     Byte(ast::Name),
     Char(ast::Name),
+    Err(ast::Name),
     Integer(ast::Name),
     Float(ast::Name),
     Str_(ast::Name),
@@ -73,6 +74,7 @@ impl Lit {
         match *self {
             Byte(_) => "byte literal",
             Char(_) => "char literal",
+            Err(_) => "error literal",
             Integer(_) => "integer literal",
             Float(_) => "float literal",
             Str_(_) | StrRaw(..) => "string literal",
index 2ad3d3a6d648795d112c9cbd05e351d7249e88f1..123f9b49692d97217c6770ef4ca9d96b242f6e54 100644 (file)
@@ -224,6 +224,7 @@ pub fn token_to_string(tok: &Token) -> String {
             let mut out = match lit {
                 token::Byte(b)           => format!("b'{}'", b),
                 token::Char(c)           => format!("'{}'", c),
+                token::Err(c)            => format!("'{}'", c),
                 token::Float(c)          |
                 token::Integer(c)        => c.to_string(),
                 token::Str_(s)           => format!("\"{}\"", s),