diff --git a/compiler/rustc_ast/src/util/literal.rs b/compiler/rustc_ast/src/util/literal.rs index db2ac9626af..8eec869fbe5 100644 --- a/compiler/rustc_ast/src/util/literal.rs +++ b/compiler/rustc_ast/src/util/literal.rs @@ -2,7 +2,6 @@ use crate::ast::{self, Lit, LitKind}; use crate::token::{self, Token}; -use rustc_data_structures::sync::Lrc; use rustc_lexer::unescape::{byte_from_char, unescape_byte, unescape_char, unescape_literal, Mode}; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; @@ -215,13 +214,6 @@ impl Lit { Lit { token_lit: kind.to_token_lit(), kind, span } } - /// Recovers an AST literal from a string of bytes produced by `include_bytes!`. - /// This requires ASCII-escaping the string, which can result in poor performance - /// for very large strings of bytes. - pub fn from_included_bytes(bytes: &Lrc<[u8]>, span: Span) -> Lit { - Self::from_lit_kind(LitKind::ByteStr(bytes.clone()), span) - } - /// Losslessly convert an AST literal into a token. pub fn to_token(&self) -> Token { let kind = match self.token_lit.kind { diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 949d98f96ab..f4d77549eff 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -328,8 +328,8 @@ impl<'a> State<'a> { self.print_token_literal(token_lit, expr.span); } ast::ExprKind::IncludedBytes(ref bytes) => { - let lit = ast::Lit::from_included_bytes(bytes, expr.span); - self.print_literal(&lit) + let lit = ast::LitKind::ByteStr(bytes.clone()).to_token_lit(); + self.print_token_literal(lit, expr.span) } ast::ExprKind::Cast(ref expr, ref ty) => { let prec = AssocOp::As.precedence() as i8; diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 2e832deeecd..b69556c0e7c 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -526,9 +526,9 @@ impl server::TokenStream for Rustc<'_, '_> { 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); + let lit = ast::LitKind::ByteStr(bytes.clone()).to_token_lit(); Ok(tokenstream::TokenStream::token_alone( - token::TokenKind::Literal(lit.token_lit), + token::TokenKind::Literal(lit), expr.span, )) }