Skip to content

Commit

Permalink
Rollup merge of rust-lang#100018 - nnethercote:clean-up-LitKind, r=pe…
Browse files Browse the repository at this point in the history
…trochenkov

Clean up `LitKind`

r? ``@petrochenkov``
  • Loading branch information
matthiaskrgr authored Aug 17, 2022
2 parents 6e5f90a + e92183c commit 37eeed7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/octal_escapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ impl EarlyLintPass for OctalEscapes {
}

if let ExprKind::Lit(lit) = &expr.kind {
if matches!(lit.token.kind, LitKind::Str) {
check_lit(cx, &lit.token, lit.span, true);
} else if matches!(lit.token.kind, LitKind::ByteStr) {
check_lit(cx, &lit.token, lit.span, false);
if matches!(lit.token_lit.kind, LitKind::Str) {
check_lit(cx, &lit.token_lit, lit.span, true);
} else if matches!(lit.token_lit.kind, LitKind::ByteStr) {
check_lit(cx, &lit.token_lit, lit.span, false);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,12 @@ impl Write {
},
};

let replacement: String = match lit.token.kind {
let replacement: String = match lit.token_lit.kind {
LitKind::StrRaw(_) | LitKind::ByteStrRaw(_) if matches!(fmtstr.style, StrStyle::Raw(_)) => {
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
},
LitKind::Str | LitKind::ByteStr if matches!(fmtstr.style, StrStyle::Cooked) => {
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
},
LitKind::StrRaw(_)
| LitKind::Str
Expand All @@ -603,7 +603,7 @@ impl Write {
| LitKind::Integer
| LitKind::Float
| LitKind::Err => continue,
LitKind::Byte | LitKind::Char => match lit.token.symbol.as_str() {
LitKind::Byte | LitKind::Char => match lit.token_lit.symbol.as_str() {
"\"" if matches!(fmtstr.style, StrStyle::Cooked) => "\\\"",
"\"" if matches!(fmtstr.style, StrStyle::Raw(0)) => continue,
"\\\\" if matches!(fmtstr.style, StrStyle::Raw(_)) => "\\",
Expand All @@ -614,7 +614,7 @@ impl Write {
x => x,
}
.into(),
LitKind::Bool => lit.token.symbol.as_str().deref().into(),
LitKind::Bool => lit.token_lit.symbol.as_str().deref().into(),
};

if !fmt_spans.is_empty() {
Expand Down

0 comments on commit 37eeed7

Please sign in to comment.