Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Clean up `LitKind` r? ``@petrochenkov``
This commit is contained in:
commit
d5dca26a94
19 changed files with 73 additions and 66 deletions
|
@ -1,6 +1,5 @@
|
|||
use rustc_ast as ast;
|
||||
use rustc_ast::{ptr::P, tokenstream::TokenStream};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_expand::base::{self, DummyResult};
|
||||
|
||||
|
@ -185,5 +184,5 @@ pub fn expand_concat_bytes(
|
|||
return base::MacEager::expr(DummyResult::raw_expr(sp, true));
|
||||
}
|
||||
let sp = cx.with_def_site_ctxt(sp);
|
||||
base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::from(accumulator))))
|
||||
base::MacEager::expr(cx.expr_byte_str(sp, accumulator))
|
||||
}
|
||||
|
|
|
@ -126,9 +126,9 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool {
|
|||
}
|
||||
|
||||
fn report_unexpected_literal(sess: &Session, lit: &ast::Lit) {
|
||||
let help_msg = match lit.token.kind {
|
||||
token::Str if rustc_lexer::is_ident(lit.token.symbol.as_str()) => {
|
||||
format!("try using `#[derive({})]`", lit.token.symbol)
|
||||
let help_msg = match lit.token_lit.kind {
|
||||
token::Str if rustc_lexer::is_ident(lit.token_lit.symbol.as_str()) => {
|
||||
format!("try using `#[derive({})]`", lit.token_lit.symbol)
|
||||
}
|
||||
_ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(),
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
|
|||
|
||||
// We want to make sure we have the ctxt set so that we can use unstable methods
|
||||
let span = cx.with_def_site_ctxt(span);
|
||||
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
|
||||
let name = cx.expr_str(span, ident.name);
|
||||
let fmt = substr.nonselflike_args[0].clone();
|
||||
|
||||
// Struct and tuples are similar enough that we use the same code for both,
|
||||
|
@ -89,10 +89,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
|
|||
for i in 0..fields.len() {
|
||||
let field = &fields[i];
|
||||
if is_struct {
|
||||
let name = cx.expr_lit(
|
||||
field.span,
|
||||
ast::LitKind::Str(field.name.unwrap().name, ast::StrStyle::Cooked),
|
||||
);
|
||||
let name = cx.expr_str(field.span, field.name.unwrap().name);
|
||||
args.push(name);
|
||||
}
|
||||
// Use an extra indirection to make sure this works for unsized types.
|
||||
|
@ -108,10 +105,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
|
|||
|
||||
for field in fields {
|
||||
if is_struct {
|
||||
name_exprs.push(cx.expr_lit(
|
||||
field.span,
|
||||
ast::LitKind::Str(field.name.unwrap().name, ast::StrStyle::Cooked),
|
||||
));
|
||||
name_exprs.push(cx.expr_str(field.span, field.name.unwrap().name));
|
||||
}
|
||||
|
||||
// Use an extra indirection to make sure this works for unsized types.
|
||||
|
|
|
@ -923,7 +923,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
}
|
||||
|
||||
// Build the format
|
||||
let fill = self.ecx.expr_lit(sp, ast::LitKind::Char(fill));
|
||||
let fill = self.ecx.expr_char(sp, fill);
|
||||
let align = |name| {
|
||||
let mut p = Context::rtpath(self.ecx, sym::Alignment);
|
||||
p.push(Ident::new(name, sp));
|
||||
|
|
|
@ -216,7 +216,7 @@ pub fn expand_include_bytes(
|
|||
}
|
||||
};
|
||||
match cx.source_map().load_binary_file(&file) {
|
||||
Ok(bytes) => base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(bytes.into()))),
|
||||
Ok(bytes) => base::MacEager::expr(cx.expr_byte_str(sp, bytes)),
|
||||
Err(e) => {
|
||||
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
|
||||
DummyResult::any(sp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue