Use variable names directly in the format strings (#7906)

# Description

Lint: `clippy::uninlined_format_args`

More readable in most situations.
(May be slightly confusing for modifier format strings
https://doc.rust-lang.org/std/fmt/index.html#formatting-parameters)

Alternative to #7865

# User-Facing Changes

None intended

# Tests + Formatting

(Ran `cargo +stable clippy --fix --workspace -- -A clippy::all -D
clippy::uninlined_format_args` to achieve this. Depends on Rust `1.67`)
This commit is contained in:
Stefan Holderbach
2023-01-30 02:37:54 +01:00
committed by GitHub
parent 6ae497eedc
commit ab480856a5
134 changed files with 386 additions and 431 deletions

View File

@@ -239,7 +239,7 @@ fn create_grid_output(
Value::string(grid_display.to_string(), call.head)
} else {
Value::String {
val: format!("Couldn't fit grid into {} columns!", cols),
val: format!("Couldn't fit grid into {cols} columns!"),
span: call.head,
}
}

View File

@@ -320,7 +320,7 @@ fn handle_table_command(
} else {
// assume this failed because the table was too wide
// TODO: more robust error classification
format!("Couldn't fit table into {} columns!", term_width)
format!("Couldn't fit table into {term_width} columns!")
}
});
@@ -1481,7 +1481,7 @@ fn convert_with_precision(val: &str, precision: usize) -> Result<String, ShellEr
));
}
};
Ok(format!("{:.prec$}", val_float, prec = precision))
Ok(format!("{val_float:.precision$}"))
}
fn is_cfg_trim_keep_words(config: &Config) -> bool {
@@ -1696,7 +1696,7 @@ impl Iterator for PagingTableCreator {
// assume this failed because the table was too wide
// TODO: more robust error classification
let term_width = get_width_param(self.width_param);
format!("Couldn't fit table into {} columns!", term_width)
format!("Couldn't fit table into {term_width} columns!")
};
Some(Ok(msg.as_bytes().to_vec()))
}