Skip to content

Commit 53d1a66

Browse files
Rollup merge of #131733 - practicalrs:fix_uninlined_format_args, r=jieyouxu
Fix uninlined_format_args in stable_mir Hi, This PR fixes some clippy warnings ``` warning: variables can be used directly in the `format!` string --> compiler/stable_mir/src/mir/pretty.rs:362:13 | 362 | write!(writer, "{kind}{:?}", place) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: requested on the command line with `-W clippy::uninlined-format-args` help: change this to | 362 - write!(writer, "{kind}{:?}", place) 362 + write!(writer, "{kind}{place:?}") | ``` Best regards, Michal
2 parents fc1ad2e + d3d5905 commit 53d1a66

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

compiler/stable_mir/src/mir/pretty.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Debug for Place {
2222
}
2323

2424
pub(crate) fn function_body<W: Write>(writer: &mut W, body: &Body, name: &str) -> io::Result<()> {
25-
write!(writer, "fn {}(", name)?;
25+
write!(writer, "fn {name}(")?;
2626
body.arg_locals()
2727
.iter()
2828
.enumerate()
@@ -54,7 +54,7 @@ pub(crate) fn function_body<W: Write>(writer: &mut W, body: &Body, name: &str) -
5454
.iter()
5555
.enumerate()
5656
.map(|(index, block)| -> io::Result<()> {
57-
writeln!(writer, " bb{}: {{", index)?;
57+
writeln!(writer, " bb{index}: {{")?;
5858
let _ = block
5959
.statements
6060
.iter()
@@ -75,7 +75,7 @@ pub(crate) fn function_body<W: Write>(writer: &mut W, body: &Body, name: &str) -
7575
fn pretty_statement<W: Write>(writer: &mut W, statement: &StatementKind) -> io::Result<()> {
7676
match statement {
7777
StatementKind::Assign(place, rval) => {
78-
write!(writer, " {:?} = ", place)?;
78+
write!(writer, " {place:?} = ")?;
7979
pretty_rvalue(writer, rval)?;
8080
writeln!(writer, ";")
8181
}
@@ -165,7 +165,7 @@ fn pretty_terminator_head<W: Write>(writer: &mut W, terminator: &TerminatorKind)
165165
Abort => write!(writer, "{INDENT}abort"),
166166
Return => write!(writer, "{INDENT}return"),
167167
Unreachable => write!(writer, "{INDENT}unreachable"),
168-
Drop { place, .. } => write!(writer, "{INDENT}drop({:?})", place),
168+
Drop { place, .. } => write!(writer, "{INDENT}drop({place:?})"),
169169
Call { func, args, destination, .. } => {
170170
write!(writer, "{INDENT}{:?} = {}(", destination, pretty_operand(func))?;
171171
let mut args_iter = args.iter();
@@ -304,10 +304,10 @@ fn pretty_assert_message<W: Write>(writer: &mut W, msg: &AssertMessage) -> io::R
304304
fn pretty_operand(operand: &Operand) -> String {
305305
match operand {
306306
Operand::Copy(copy) => {
307-
format!("{:?}", copy)
307+
format!("{copy:?}")
308308
}
309309
Operand::Move(mv) => {
310-
format!("move {:?}", mv)
310+
format!("move {mv:?}")
311311
}
312312
Operand::Constant(cnst) => pretty_mir_const(&cnst.const_),
313313
}
@@ -344,13 +344,13 @@ fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
344344
write!(writer, "Checked{:?}({}, {})", bin, pretty_operand(op1), pretty_operand(op2))
345345
}
346346
Rvalue::CopyForDeref(deref) => {
347-
write!(writer, "CopyForDeref({:?})", deref)
347+
write!(writer, "CopyForDeref({deref:?})")
348348
}
349349
Rvalue::Discriminant(place) => {
350-
write!(writer, "discriminant({:?})", place)
350+
write!(writer, "discriminant({place:?})")
351351
}
352352
Rvalue::Len(len) => {
353-
write!(writer, "len({:?})", len)
353+
write!(writer, "len({len:?})")
354354
}
355355
Rvalue::Ref(_, borrowkind, place) => {
356356
let kind = match borrowkind {
@@ -359,17 +359,17 @@ fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
359359
BorrowKind::Fake(FakeBorrowKind::Shallow) => "&fake shallow ",
360360
BorrowKind::Mut { .. } => "&mut ",
361361
};
362-
write!(writer, "{kind}{:?}", place)
362+
write!(writer, "{kind}{place:?}")
363363
}
364364
Rvalue::Repeat(op, cnst) => {
365365
write!(writer, "{} \" \" {}", pretty_operand(op), pretty_ty_const(cnst))
366366
}
367367
Rvalue::ShallowInitBox(_, _) => Ok(()),
368368
Rvalue::ThreadLocalRef(item) => {
369-
write!(writer, "thread_local_ref{:?}", item)
369+
write!(writer, "thread_local_ref{item:?}")
370370
}
371371
Rvalue::NullaryOp(nul, ty) => {
372-
write!(writer, "{:?} {} \" \"", nul, ty)
372+
write!(writer, "{nul:?} {ty} \" \"")
373373
}
374374
Rvalue::UnaryOp(un, op) => {
375375
write!(writer, "{} \" \" {:?}", pretty_operand(op), un)

0 commit comments

Comments
 (0)