Rename some things related to literals.
- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is `token::Lit`, which is not a token. (This has been confusing me for a long time.) reasonable because we have an `ast::token::Lit` inside an `ast::Lit`. - Rename `LitKind::{from,to}_lit_token` as `LitKind::{from,to}_token_lit`, to match the above change and `token::Lit`.
This commit is contained in:
parent
d7a041f607
commit
5d3cc1713a
13 changed files with 49 additions and 41 deletions
|
@ -486,20 +486,26 @@ impl server::TokenStream for Rustc<'_, '_> {
|
|||
// We don't use `TokenStream::from_ast` as the tokenstream currently cannot
|
||||
// be recovered in the general case.
|
||||
match &expr.kind {
|
||||
ast::ExprKind::Lit(l) if l.token.kind == token::Bool => Ok(
|
||||
tokenstream::TokenStream::token_alone(token::Ident(l.token.symbol, false), l.span),
|
||||
),
|
||||
ast::ExprKind::Lit(l) if l.token_lit.kind == token::Bool => {
|
||||
Ok(tokenstream::TokenStream::token_alone(
|
||||
token::Ident(l.token_lit.symbol, false),
|
||||
l.span,
|
||||
))
|
||||
}
|
||||
ast::ExprKind::Lit(l) => {
|
||||
Ok(tokenstream::TokenStream::token_alone(token::Literal(l.token), l.span))
|
||||
Ok(tokenstream::TokenStream::token_alone(token::Literal(l.token_lit), l.span))
|
||||
}
|
||||
ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {
|
||||
ast::ExprKind::Lit(l) => match l.token {
|
||||
ast::ExprKind::Lit(l) => match l.token_lit {
|
||||
token::Lit { kind: token::Integer | token::Float, .. } => {
|
||||
Ok(Self::TokenStream::from_iter([
|
||||
// FIXME: The span of the `-` token is lost when
|
||||
// parsing, so we cannot faithfully recover it here.
|
||||
tokenstream::TokenTree::token_alone(token::BinOp(token::Minus), e.span),
|
||||
tokenstream::TokenTree::token_alone(token::Literal(l.token), l.span),
|
||||
tokenstream::TokenTree::token_alone(
|
||||
token::Literal(l.token_lit),
|
||||
l.span,
|
||||
),
|
||||
]))
|
||||
}
|
||||
_ => Err(()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue