Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
This commit is contained in:
commit
2cd2070af7
28 changed files with 244 additions and 171 deletions
|
@ -69,7 +69,7 @@ fn invalid_type_err(
|
|||
Ok(ast::LitKind::Int(_, _)) => {
|
||||
cx.span_err(span, "numeric literal is not a `u8`");
|
||||
}
|
||||
Ok(ast::LitKind::ByteStr(_) | ast::LitKind::Byte(_)) => unreachable!(),
|
||||
Ok(ast::LitKind::ByteStr(..) | ast::LitKind::Byte(_)) => unreachable!(),
|
||||
Err(err) => {
|
||||
report_lit_error(&cx.sess.parse_sess, err, token_lit, span);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ fn handle_array_element(
|
|||
)) if val <= u8::MAX.into() => Some(val as u8),
|
||||
|
||||
Ok(ast::LitKind::Byte(val)) => Some(val),
|
||||
Ok(ast::LitKind::ByteStr(_)) => {
|
||||
Ok(ast::LitKind::ByteStr(..)) => {
|
||||
if !*has_errors {
|
||||
cx.struct_span_err(expr.span, "cannot concatenate doubly nested array")
|
||||
.note("byte strings are treated as arrays of bytes")
|
||||
|
@ -174,7 +174,7 @@ pub fn expand_concat_bytes(
|
|||
Ok(ast::LitKind::Byte(val)) => {
|
||||
accumulator.push(val);
|
||||
}
|
||||
Ok(ast::LitKind::ByteStr(ref bytes)) => {
|
||||
Ok(ast::LitKind::ByteStr(ref bytes, _)) => {
|
||||
accumulator.extend_from_slice(&bytes);
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::cfg_eval::cfg_eval;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::{token, GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind};
|
||||
use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind};
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
|
||||
use rustc_feature::AttributeTemplate;
|
||||
|
@ -130,9 +130,11 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool {
|
|||
}
|
||||
|
||||
fn report_unexpected_meta_item_lit(sess: &Session, lit: &ast::MetaItemLit) {
|
||||
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)
|
||||
let help_msg = match lit.kind {
|
||||
ast::LitKind::Str(_, ast::StrStyle::Cooked)
|
||||
if rustc_lexer::is_ident(lit.symbol.as_str()) =>
|
||||
{
|
||||
format!("try using `#[derive({})]`", lit.symbol)
|
||||
}
|
||||
_ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue