Add StrStyle
to ast::LitKind::ByteStr
.
This is required to distinguish between cooked and raw byte string literals in an `ast::LitKind`, without referring to an adjacent `token::Lit`. It's a prerequisite for the next commit.
This commit is contained in:
parent
e658144586
commit
a7f35c42d4
18 changed files with 39 additions and 28 deletions
|
@ -1234,7 +1234,7 @@ pub fn expr_to_spanned_string<'a>(
|
|||
Err(match expr.kind {
|
||||
ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) {
|
||||
Ok(ast::LitKind::Str(s, style)) => return Ok((s, style, expr.span)),
|
||||
Ok(ast::LitKind::ByteStr(_)) => {
|
||||
Ok(ast::LitKind::ByteStr(..)) => {
|
||||
let mut err = cx.struct_span_err(expr.span, err_msg);
|
||||
let span = expr.span.shrink_to_lo();
|
||||
err.span_suggestion(
|
||||
|
|
|
@ -361,7 +361,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
}
|
||||
|
||||
pub fn expr_byte_str(&self, sp: Span, bytes: Vec<u8>) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitKind::ByteStr(Lrc::from(bytes)))
|
||||
self.expr_lit(sp, ast::LitKind::ByteStr(Lrc::from(bytes), ast::StrStyle::Cooked))
|
||||
}
|
||||
|
||||
/// `[expr1, expr2, ...]`
|
||||
|
|
|
@ -526,7 +526,8 @@ impl server::TokenStream for Rustc<'_, '_> {
|
|||
Ok(tokenstream::TokenStream::token_alone(token::Literal(*token_lit), expr.span))
|
||||
}
|
||||
ast::ExprKind::IncludedBytes(bytes) => {
|
||||
let lit = ast::LitKind::ByteStr(bytes.clone()).synthesize_token_lit();
|
||||
let lit = ast::LitKind::ByteStr(bytes.clone(), ast::StrStyle::Cooked)
|
||||
.synthesize_token_lit();
|
||||
Ok(tokenstream::TokenStream::token_alone(token::TokenKind::Literal(lit), expr.span))
|
||||
}
|
||||
ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue