Skip to content

Commit 568e647

Browse files
committed
Remove three uses of LitKind::synthesize_token_lit.
1 parent d887615 commit 568e647

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

compiler/rustc_ast/src/attr/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
use crate::ast::{AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute};
44
use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit};
55
use crate::ast::{MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem, NormalAttr};
6-
use crate::ast::{Path, PathSegment, StrStyle, DUMMY_NODE_ID};
6+
use crate::ast::{Path, PathSegment, DUMMY_NODE_ID};
77
use crate::ptr::P;
88
use crate::token::{self, CommentKind, Delimiter, Token};
99
use crate::tokenstream::{DelimSpan, Spacing, TokenTree};
1010
use crate::tokenstream::{LazyAttrTokenStream, TokenStream};
1111
use crate::util::comments;
12+
use crate::util::literal::escape_string_symbol;
1213
use rustc_data_structures::sync::WorkerLocal;
1314
use rustc_index::bit_set::GrowableBitSet;
1415
use rustc_span::symbol::{sym, Ident, Symbol};
@@ -395,7 +396,7 @@ pub fn mk_attr_name_value_str(
395396
val: Symbol,
396397
span: Span,
397398
) -> Attribute {
398-
let lit = LitKind::Str(val, StrStyle::Cooked).synthesize_token_lit();
399+
let lit = token::Lit::new(token::Str, escape_string_symbol(val), None);
399400
let expr = P(Expr {
400401
id: DUMMY_NODE_ID,
401402
kind: ExprKind::Lit(lit),

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use crate::pp::Breaks::Inconsistent;
22
use crate::pprust::state::{AnnNode, IterDelimited, PrintState, State, INDENT_UNIT};
33

44
use rustc_ast::ptr::P;
5+
use rustc_ast::token;
6+
use rustc_ast::util::literal::escape_byte_str_symbol;
57
use rustc_ast::util::parser::{self, AssocOp, Fixity};
68
use rustc_ast::{self as ast, BlockCheckMode};
79

@@ -323,8 +325,7 @@ impl<'a> State<'a> {
323325
self.print_token_literal(*token_lit, expr.span);
324326
}
325327
ast::ExprKind::IncludedBytes(bytes) => {
326-
let lit = ast::LitKind::ByteStr(bytes.clone(), ast::StrStyle::Cooked)
327-
.synthesize_token_lit();
328+
let lit = token::Lit::new(token::ByteStr, escape_byte_str_symbol(bytes), None);
328329
self.print_token_literal(lit, expr.span)
329330
}
330331
ast::ExprKind::Cast(expr, ty) => {

compiler/rustc_expand/src/proc_macro_server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use pm::{Delimiter, Level, LineColumn};
66
use rustc_ast as ast;
77
use rustc_ast::token;
88
use rustc_ast::tokenstream::{self, Spacing::*, TokenStream};
9+
use rustc_ast::util::literal::escape_byte_str_symbol;
910
use rustc_ast_pretty::pprust;
1011
use rustc_data_structures::fx::FxHashMap;
1112
use rustc_data_structures::sync::Lrc;
@@ -526,8 +527,7 @@ impl server::TokenStream for Rustc<'_, '_> {
526527
Ok(tokenstream::TokenStream::token_alone(token::Literal(*token_lit), expr.span))
527528
}
528529
ast::ExprKind::IncludedBytes(bytes) => {
529-
let lit = ast::LitKind::ByteStr(bytes.clone(), ast::StrStyle::Cooked)
530-
.synthesize_token_lit();
530+
let lit = token::Lit::new(token::ByteStr, escape_byte_str_symbol(bytes), None);
531531
Ok(tokenstream::TokenStream::token_alone(token::TokenKind::Literal(lit), expr.span))
532532
}
533533
ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {

0 commit comments

Comments
 (0)