Skip to content

Commit 17a092f

Browse files
committed
Auto merge of rust-lang#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`
2 parents dc50bb0 + 6481d37 commit 17a092f

File tree

6 files changed

+8
-6
lines changed

6 files changed

+8
-6
lines changed

clippy_lints/src/invalid_utf8_in_unchecked.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidUtf8InUnchecked {
3333
if let Some([arg]) = match_function_call(cx, expr, &paths::STR_FROM_UTF8_UNCHECKED) {
3434
match &arg.kind {
3535
ExprKind::Lit(Spanned { node: lit, .. }) => {
36-
if let LitKind::ByteStr(bytes) = &lit
36+
if let LitKind::ByteStr(bytes, _) = &lit
3737
&& std::str::from_utf8(bytes).is_err()
3838
{
3939
lint(cx, expr.span);

clippy_lints/src/large_include_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl LateLintPass<'_> for LargeIncludeFile {
6060
then {
6161
let len = match &lit.node {
6262
// include_bytes
63-
LitKind::ByteStr(bstr) => bstr.len(),
63+
LitKind::ByteStr(bstr, _) => bstr.len(),
6464
// include_str
6565
LitKind::Str(sym, _) => sym.as_str().len(),
6666
_ => return,

clippy_lints/src/matches/match_same_arms.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<'a> NormalizedPat<'a> {
282282
// TODO: Handle negative integers. They're currently treated as a wild match.
283283
ExprKind::Lit(lit) => match lit.node {
284284
LitKind::Str(sym, _) => Self::LitStr(sym),
285-
LitKind::ByteStr(ref bytes) => Self::LitBytes(bytes),
285+
LitKind::ByteStr(ref bytes, _) => Self::LitBytes(bytes),
286286
LitKind::Byte(val) => Self::LitInt(val.into()),
287287
LitKind::Char(val) => Self::LitInt(val.into()),
288288
LitKind::Int(val, _) => Self::LitInt(val),

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
299299
};
300300
kind!("Float(_, {float_ty})");
301301
},
302-
LitKind::ByteStr(ref vec) => {
302+
LitKind::ByteStr(ref vec, _) => {
303303
bind!(self, vec);
304304
kind!("ByteStr(ref {vec})");
305305
chain!(self, "let [{:?}] = **{vec}", vec.value);

clippy_utils/src/check_proc_macro.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ fn lit_search_pat(lit: &LitKind) -> (Pat, Pat) {
6969
LitKind::Str(_, StrStyle::Cooked) => (Pat::Str("\""), Pat::Str("\"")),
7070
LitKind::Str(_, StrStyle::Raw(0)) => (Pat::Str("r"), Pat::Str("\"")),
7171
LitKind::Str(_, StrStyle::Raw(_)) => (Pat::Str("r#"), Pat::Str("#")),
72-
LitKind::ByteStr(_) => (Pat::Str("b\""), Pat::Str("\"")),
72+
LitKind::ByteStr(_, StrStyle::Cooked) => (Pat::Str("b\""), Pat::Str("\"")),
73+
LitKind::ByteStr(_, StrStyle::Raw(0)) => (Pat::Str("br\""), Pat::Str("\"")),
74+
LitKind::ByteStr(_, StrStyle::Raw(_)) => (Pat::Str("br#\""), Pat::Str("#")),
7375
LitKind::Byte(_) => (Pat::Str("b'"), Pat::Str("'")),
7476
LitKind::Char(_) => (Pat::Str("'"), Pat::Str("'")),
7577
LitKind::Int(_, LitIntType::Signed(IntTy::Isize)) => (Pat::Num, Pat::Str("isize")),

clippy_utils/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn lit_to_mir_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
210210
match *lit {
211211
LitKind::Str(ref is, _) => Constant::Str(is.to_string()),
212212
LitKind::Byte(b) => Constant::Int(u128::from(b)),
213-
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
213+
LitKind::ByteStr(ref s, _) => Constant::Binary(Lrc::clone(s)),
214214
LitKind::Char(c) => Constant::Char(c),
215215
LitKind::Int(n, _) => Constant::Int(n),
216216
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {

0 commit comments

Comments
 (0)