diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-05 13:24:54 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-06 14:04:02 +0300 |
| commit | 350a34f85c0ed53315a2114f0001cfea4fe116d9 (patch) | |
| tree | e9a92eaa132a515754574e39c588cbb01e6b5ef6 /src/libsyntax | |
| parent | f745e5f9b676be02cc1dfbab0bfb338dc72b4dd3 (diff) | |
| download | rust-350a34f85c0ed53315a2114f0001cfea4fe116d9.tar.gz rust-350a34f85c0ed53315a2114f0001cfea4fe116d9.zip | |
syntax: Use `Token` in some more places
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/literal.rs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 39ffabaa4a9..cc16bac320d 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -560,7 +560,7 @@ impl MetaItemKind { Some(TokenTree::Token(token)) if token == token::Eq => { tokens.next(); return if let Some(TokenTree::Token(token)) = tokens.next() { - Lit::from_token(&token, token.span).ok().map(MetaItemKind::NameValue) + Lit::from_token(&token).ok().map(MetaItemKind::NameValue) } else { None }; @@ -605,7 +605,7 @@ impl NestedMetaItem { where I: Iterator<Item = TokenTree>, { if let Some(TokenTree::Token(token)) = tokens.peek() { - if let Ok(lit) = Lit::from_token(token, token.span) { + if let Ok(lit) = Lit::from_token(token) { tokens.next(); return Some(NestedMetaItem::Literal(lit)); } diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index 7b27304071c..7b213655abd 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -228,8 +228,8 @@ impl Lit { } /// Converts arbitrary token into an AST literal. - crate fn from_token(token: &TokenKind, span: Span) -> Result<Lit, LitError> { - let lit = match *token { + crate fn from_token(token: &Token) -> Result<Lit, LitError> { + let lit = match token.kind { token::Ident(name, false) if name == kw::True || name == kw::False => token::Lit::new(token::Bool, name, None), token::Literal(lit) => @@ -245,7 +245,7 @@ impl Lit { _ => return Err(LitError::NotLiteral) }; - Lit::from_lit_token(lit, span) + Lit::from_lit_token(lit, token.span) } /// Attempts to recover an AST literal from semantic literal. @@ -297,7 +297,7 @@ impl<'a> Parser<'a> { } let token = recovered.as_ref().unwrap_or(&self.token); - match Lit::from_token(token, token.span) { + match Lit::from_token(token) { Ok(lit) => { self.bump(); Ok(lit) |
