Auto merge of #98463 - mystor:expand_expr_bool, r=eddyb
proc_macro: Fix expand_expr expansion of bool literals Previously, the expand_expr method would expand bool literals as a `Literal` token containing a `LitKind::Bool`, rather than as an `Ident`. This is not a valid token, and the `LitKind::Bool` case needs to be handled seperately. Tests were added to more deeply compare the streams in the expand-expr test suite to catch mistakes like this in the future.
This commit is contained in:
commit
29554c0a12
2 changed files with 74 additions and 1 deletions
|
@ -426,6 +426,10 @@ 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::TokenTree::token(token::Ident(l.token.symbol, false), l.span)
|
||||
.into())
|
||||
}
|
||||
ast::ExprKind::Lit(l) => {
|
||||
Ok(tokenstream::TokenTree::token(token::Literal(l.token), l.span).into())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue