Skip to content
Permalink
Browse files

syntax: Use `Token` in some more places

  • Loading branch information...
petrochenkov committed Jun 5, 2019
1 parent f745e5f commit 350a34f85c0ed53315a2114f0001cfea4fe116d9
Showing with 6 additions and 6 deletions.
  1. +2 −2 src/libsyntax/attr/mod.rs
  2. +4 −4 src/libsyntax/parse/literal.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));
}
@@ -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)

0 comments on commit 350a34f

Please sign in to comment.
You can’t perform that action at this time.