mirror of https://github.com/rust-lang/rust.git
Remove `Lit::from_included_bytes`.
`Lit::from_included_bytes` calls `Lit::from_lit_kind`, but the two call sites only need the resulting `token::Lit`, not the full `ast::Lit`. This commit changes those call sites to use `LitKind::to_token_lit`, which means `from_included_bytes` can be removed.
This commit is contained in:
parent
8c6bf2bee7
commit
8cfc8153da
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue