about summary refs log tree commit diff
path: root/src/librustc_ast/util/literal.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-03-07 15:58:27 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-03-09 12:42:41 +0300
commit9be233cbfe134f032ed2d50f7cc66e901bbe3f6f (patch)
tree29073f8d2cf134e40c898d69696095c26c123814 /src/librustc_ast/util/literal.rs
parent5d7f67d3b109e95fb0dca8f773a2146db4eb4a93 (diff)
downloadrust-9be233cbfe134f032ed2d50f7cc66e901bbe3f6f.tar.gz
rust-9be233cbfe134f032ed2d50f7cc66e901bbe3f6f.zip
Use `Token::uninterpolate` in couple more places matching on `(Nt)Ident`
Diffstat (limited to 'src/librustc_ast/util/literal.rs')
-rw-r--r--src/librustc_ast/util/literal.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/librustc_ast/util/literal.rs b/src/librustc_ast/util/literal.rs
index ecf17efc4e0..d1757394f3a 100644
--- a/src/librustc_ast/util/literal.rs
+++ b/src/librustc_ast/util/literal.rs
@@ -191,23 +191,16 @@ impl Lit {
     ///
     /// Keep this in sync with `Token::can_begin_literal_or_bool`.
     pub fn from_token(token: &Token) -> Result<Lit, LitError> {
-        let lit = match token.kind {
+        let lit = match token.uninterpolate().kind {
             token::Ident(name, false) if name.is_bool_lit() => {
                 token::Lit::new(token::Bool, name, None)
             }
             token::Literal(lit) => lit,
             token::Interpolated(ref nt) => {
-                match &**nt {
-                    token::NtIdent(ident, false) if ident.name.is_bool_lit() => {
-                        let lit = token::Lit::new(token::Bool, ident.name, None);
-                        return Lit::from_lit_token(lit, ident.span);
+                if let token::NtExpr(expr) | token::NtLiteral(expr) = &**nt {
+                    if let ast::ExprKind::Lit(lit) = &expr.kind {
+                        return Ok(lit.clone());
                     }
-                    token::NtExpr(expr) | token::NtLiteral(expr) => {
-                        if let ast::ExprKind::Lit(lit) = &expr.kind {
-                            return Ok(lit.clone());
-                        }
-                    }
-                    _ => {}
                 }
                 return Err(LitError::NotLiteral);
             }