Skip to content

Commit e92183c

Browse files
committed
Rename some things related to literals.
- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is `token::Lit`, which is not a token. (This has been confusing me for a long time.) reasonable because we have an `ast::token::Lit` inside an `ast::Lit`. - Rename `LitKind::{from,to}_lit_token` as `LitKind::{from,to}_token_lit`, to match the above change and `token::Lit`.
1 parent 86a0a18 commit e92183c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clippy_lints/src/octal_escapes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ impl EarlyLintPass for OctalEscapes {
5757
}
5858

5959
if let ExprKind::Lit(lit) = &expr.kind {
60-
if matches!(lit.token.kind, LitKind::Str) {
61-
check_lit(cx, &lit.token, lit.span, true);
62-
} else if matches!(lit.token.kind, LitKind::ByteStr) {
63-
check_lit(cx, &lit.token, lit.span, false);
60+
if matches!(lit.token_lit.kind, LitKind::Str) {
61+
check_lit(cx, &lit.token_lit, lit.span, true);
62+
} else if matches!(lit.token_lit.kind, LitKind::ByteStr) {
63+
check_lit(cx, &lit.token_lit, lit.span, false);
6464
}
6565
}
6666
}

clippy_lints/src/write.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,12 @@ impl Write {
589589
},
590590
};
591591

592-
let replacement: String = match lit.token.kind {
592+
let replacement: String = match lit.token_lit.kind {
593593
LitKind::StrRaw(_) | LitKind::ByteStrRaw(_) if matches!(fmtstr.style, StrStyle::Raw(_)) => {
594-
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
594+
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
595595
},
596596
LitKind::Str | LitKind::ByteStr if matches!(fmtstr.style, StrStyle::Cooked) => {
597-
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
597+
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
598598
},
599599
LitKind::StrRaw(_)
600600
| LitKind::Str
@@ -603,7 +603,7 @@ impl Write {
603603
| LitKind::Integer
604604
| LitKind::Float
605605
| LitKind::Err => continue,
606-
LitKind::Byte | LitKind::Char => match lit.token.symbol.as_str() {
606+
LitKind::Byte | LitKind::Char => match lit.token_lit.symbol.as_str() {
607607
"\"" if matches!(fmtstr.style, StrStyle::Cooked) => "\\\"",
608608
"\"" if matches!(fmtstr.style, StrStyle::Raw(0)) => continue,
609609
"\\\\" if matches!(fmtstr.style, StrStyle::Raw(_)) => "\\",
@@ -614,7 +614,7 @@ impl Write {
614614
x => x,
615615
}
616616
.into(),
617-
LitKind::Bool => lit.token.symbol.as_str().deref().into(),
617+
LitKind::Bool => lit.token_lit.symbol.as_str().deref().into(),
618618
};
619619

620620
if !fmt_spans.is_empty() {

0 commit comments

Comments
 (0)