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 e97825e + e5b5f56 commit 870ed72
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub(crate) fn format_expr(
if let Some(expr_rw) = rewrite_literal(context, l, shape) {
Some(expr_rw)
} else {
if let LitKind::StrRaw(_) = l.token.kind {
if let LitKind::StrRaw(_) = l.token_lit.kind {
Some(context.snippet(l.span).trim().into())
} else {
None
Expand Down Expand Up @@ -1226,7 +1226,7 @@ fn rewrite_string_lit(context: &RewriteContext<'_>, span: Span, shape: Shape) ->

fn rewrite_int_lit(context: &RewriteContext<'_>, lit: &ast::Lit, shape: Shape) -> Option<String> {
let span = lit.span;
let symbol = lit.token.symbol.as_str();
let symbol = lit.token_lit.symbol.as_str();

if let Some(symbol_stripped) = symbol.strip_prefix("0x") {
let hex_lit = match context.config.hex_literal_case() {
Expand All @@ -1239,7 +1239,9 @@ fn rewrite_int_lit(context: &RewriteContext<'_>, lit: &ast::Lit, shape: Shape) -
format!(
"0x{}{}",
hex_lit,
lit.token.suffix.map_or(String::new(), |s| s.to_string())
lit.token_lit
.suffix
.map_or(String::new(), |s| s.to_string())
),
context.config.max_width(),
shape,
Expand Down

0 comments on commit 870ed72

Please sign in to comment.