X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_expand%2Fsrc%2Fproc_macro_server.rs;h=2e832deeecda0ed0645bbde1d4a5ec6da2ccf808;hb=a1e5fea13610ba651b6eec034b85377ead87eb7c;hp=cc2858d3f73a17d80a95147a4353501ca82cc5b4;hpb=a7cd4f2edf67a3c896f47333d68999f3d5a0cc1f;p=rust.git diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index cc2858d3f73..2e832deeecd 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -516,26 +516,30 @@ fn expand_expr(&mut self, stream: &Self::TokenStream) -> Result { + ast::ExprKind::Lit(token_lit) if token_lit.kind == token::Bool => { Ok(tokenstream::TokenStream::token_alone( - token::Ident(l.token_lit.symbol, false), - l.span, + token::Ident(token_lit.symbol, false), + expr.span, )) } - ast::ExprKind::Lit(l) => { - Ok(tokenstream::TokenStream::token_alone(token::Literal(l.token_lit), l.span)) + ast::ExprKind::Lit(token_lit) => { + Ok(tokenstream::TokenStream::token_alone(token::Literal(*token_lit), expr.span)) + } + ast::ExprKind::IncludedBytes(bytes) => { + let lit = ast::Lit::from_included_bytes(bytes, expr.span); + Ok(tokenstream::TokenStream::token_alone( + token::TokenKind::Literal(lit.token_lit), + expr.span, + )) } ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind { - ast::ExprKind::Lit(l) => match l.token_lit { + ast::ExprKind::Lit(token_lit) => match 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_lit), - l.span, - ), + tokenstream::TokenTree::token_alone(token::Literal(*token_lit), e.span), ])) } _ => Err(()),