Fix easy clippy lints from latest stable (#16053)

1.88.0 was released today, clippy now lints (machine-applicable)
against:
- format strings with empty braces that could be inlined
  - easy win
- `manual_abs_diff`
- returning of a stored result of the last expression.
  - this can be somewhat contentious but touched only a few places
This commit is contained in:
Stefan Holderbach
2025-06-29 17:37:17 +02:00
committed by GitHub
parent 372d576846
commit 9da0f41ebb
102 changed files with 258 additions and 339 deletions

View File

@ -89,7 +89,7 @@ impl Command for Histogram {
"frequency-column-name can't be {}",
forbidden_column_names
.iter()
.map(|val| format!("'{}'", val))
.map(|val| format!("'{val}'"))
.collect::<Vec<_>>()
.join(", ")
),

View File

@ -678,7 +678,7 @@ fn parse_value_from_record_as_u32(
Value::Int { val, .. } => {
if *val < 0 || *val > u32::MAX as i64 {
return Err(ShellError::IncorrectValue {
msg: format!("incorrect value for {}", col),
msg: format!("incorrect value for {col}"),
val_span: *head,
call_span: *span,
});

View File

@ -368,8 +368,7 @@ fn merge_record(record: &Record, head: Span, span: Span) -> Result<Value, ShellE
if !ALLOWED_SIGNS.contains(&val.as_str()) {
let allowed_signs = ALLOWED_SIGNS.join(", ");
return Err(ShellError::IncorrectValue {
msg: format!("Invalid sign. Allowed signs are {}", allowed_signs)
.to_string(),
msg: format!("Invalid sign. Allowed signs are {allowed_signs}").to_string(),
val_span: sign.span(),
call_span: head,
});

View File

@ -122,8 +122,8 @@ impl Table {
.conn
.query_row(&table_exists_query, [], |row| row.get(0))
.map_err(|err| ShellError::GenericError {
error: format!("{:#?}", err),
msg: format!("{:#?}", err),
error: format!("{err:#?}"),
msg: format!("{err:#?}"),
span: None,
help: None,
inner: Vec::new(),
@ -257,7 +257,7 @@ fn insert_in_transaction(
let insert_statement = format!(
"INSERT INTO [{}] ({}) VALUES ({})",
table_name,
Itertools::intersperse(val.columns().map(|c| format!("`{}`", c)), ", ".to_string())
Itertools::intersperse(val.columns().map(|c| format!("`{c}`")), ", ".to_string())
.collect::<String>(),
Itertools::intersperse(itertools::repeat_n("?", val.len()), ", ").collect::<String>(),
);
@ -381,7 +381,7 @@ fn get_columns_with_sqlite_types(
.map(|name| (format!("`{}`", name.0), name.1))
.any(|(name, _)| name == *c)
{
columns.push((format!("`{}`", c), nu_value_to_sqlite_type(v)?));
columns.push((format!("`{c}`"), nu_value_to_sqlite_type(v)?));
}
}

View File

@ -173,7 +173,7 @@ impl SQLiteDatabase {
filename: String,
) -> Result<(), SqliteError> {
//vacuum main into 'c:\\temp\\foo.db'
conn.execute(&format!("vacuum main into '{}'", filename), [])?;
conn.execute(&format!("vacuum main into '{filename}'"), [])?;
Ok(())
}

View File

@ -126,10 +126,10 @@ impl Command for ViewSource {
}
let _ = write!(&mut final_contents, "--{}", n.long);
if let Some(short) = n.short {
let _ = write!(&mut final_contents, "(-{})", short);
let _ = write!(&mut final_contents, "(-{short})");
}
if let Some(arg) = &n.arg {
let _ = write!(&mut final_contents, ": {}", arg);
let _ = write!(&mut final_contents, ": {arg}");
}
final_contents.push(' ');
}
@ -146,7 +146,7 @@ impl Command for ViewSource {
let mut c = 0;
for (insig, outsig) in type_signatures {
c += 1;
let s = format!("{} -> {}", insig, outsig);
let s = format!("{insig} -> {outsig}");
final_contents.push_str(&s);
if c != len {
final_contents.push_str(", ")

View File

@ -112,8 +112,8 @@ impl Command for Mktemp {
.map_err(|_| ShellError::NonUtf8 { span })?,
Err(e) => {
return Err(ShellError::GenericError {
error: format!("{}", e),
msg: format!("{}", e),
error: format!("{e}"),
msg: format!("{e}"),
span: None,
help: None,
inner: vec![],

View File

@ -198,7 +198,7 @@ impl Command for Open {
let converter = exts_opt.and_then(|exts| {
exts.iter().find_map(|ext| {
engine_state
.find_decl(format!("from {}", ext).as_bytes(), &[])
.find_decl(format!("from {ext}").as_bytes(), &[])
.map(|id| (id, ext.to_string()))
})
});
@ -314,7 +314,7 @@ fn extract_extensions(filename: &str) -> Vec<String> {
if current_extension.is_empty() {
current_extension.push_str(part);
} else {
current_extension = format!("{}.{}", part, current_extension);
current_extension = format!("{part}.{current_extension}");
}
extensions.push(current_extension.clone());
}

View File

@ -272,8 +272,8 @@ impl Command for UCp {
uu_cp::Error::NotAllFilesCopied => {}
_ => {
return Err(ShellError::GenericError {
error: format!("{}", error),
msg: format!("{}", error),
error: format!("{error}"),
msg: format!("{error}"),
span: None,
help: None,
inner: vec![],
@ -373,7 +373,7 @@ fn parse_and_set_attribute(
"xattr" => &mut attribute.xattr,
_ => {
return Err(ShellError::IncompatibleParametersSingle {
msg: format!("--preserve flag got an unexpected attribute \"{}\"", val),
msg: format!("--preserve flag got an unexpected attribute \"{val}\""),
span: value.span(),
});
}

View File

@ -77,8 +77,8 @@ impl Command for UMkdir {
for dir in directories {
if let Err(error) = mkdir(&dir, IS_RECURSIVE, get_mode(), is_verbose) {
return Err(ShellError::GenericError {
error: format!("{}", error),
msg: format!("{}", error),
error: format!("{error}"),
msg: format!("{error}"),
span: None,
help: None,
inner: vec![],

View File

@ -195,8 +195,8 @@ impl Command for UMv {
};
if let Err(error) = uu_mv::mv(&files, &options) {
return Err(ShellError::GenericError {
error: format!("{}", error),
msg: format!("{}", error),
error: format!("{error}"),
msg: format!("{error}"),
span: None,
help: None,
inner: Vec::new(),

View File

@ -220,7 +220,7 @@ impl Command for UTouch {
inner: Vec::new(),
},
TouchError::InvalidDateFormat(date) => ShellError::IncorrectValue {
msg: format!("Invalid date: {}", date),
msg: format!("Invalid date: {date}"),
val_span: date_span.expect("touch should've been given a date"),
call_span: call.head,
},

View File

@ -334,7 +334,7 @@ fn closure_variable_warning(
Cow::Owned(s) if s.deref() == "$carapace_completer" => {
carapace_suggestion.to_string()
}
_ => format!("change this to {{ {} }}", span_contents).to_string(),
_ => format!("change this to {{ {span_contents} }}").to_string(),
};
report_shell_warning(

View File

@ -379,10 +379,7 @@ fn merge_records(left: &Record, right: &Record, shared_key: Option<&str>) -> Rec
let k_shared = shared_key == Some(k.as_str());
// Do not output shared join key twice
if !(k_seen && k_shared) {
record.push(
if k_seen { format!("{}_", k) } else { k.clone() },
v.clone(),
);
record.push(if k_seen { format!("{k}_") } else { k.clone() }, v.clone());
}
}
record

View File

@ -212,7 +212,7 @@ impl From<ReadError> for ShellError {
},
ReadError::TypeMismatch(marker, span) => ShellError::GenericError {
error: "Invalid marker while reading MessagePack data".into(),
msg: format!("unexpected {:?} in data", marker),
msg: format!("unexpected {marker:?} in data"),
span: Some(span),
help: None,
inner: vec![],

View File

@ -167,7 +167,7 @@ fn parse_aligned_columns<'a>(
let headers: Vec<(String, usize)> = indices
.iter()
.enumerate()
.map(|(i, position)| (format!("column{}", i), *position))
.map(|(i, position)| (format!("column{i}"), *position))
.collect();
construct(ls.iter().map(|s| s.to_owned()), headers)

View File

@ -252,7 +252,7 @@ fn process_xml_parse_error(source: String, err: roxmltree::Error, span: Span) ->
pos,
),
roxmltree::Error::UnknownNamespace(prefix, pos) => {
make_xml_error_spanned(format!("Unknown prefix {}", prefix), source, pos)
make_xml_error_spanned(format!("Unknown prefix {prefix}"), source, pos)
}
roxmltree::Error::UnexpectedCloseTag(expected, actual, pos) => make_xml_error_spanned(
format!("Unexpected close tag {actual}, expected {expected}"),

View File

@ -158,27 +158,26 @@ fn convert_yaml_value_to_nu_value(
}
serde_yaml::Value::Tagged(t) => {
let tag = &t.tag;
let value = match &t.value {
match &t.value {
serde_yaml::Value::String(s) => {
let val = format!("{} {}", tag, s).trim().to_string();
let val = format!("{tag} {s}").trim().to_string();
Value::string(val, span)
}
serde_yaml::Value::Number(n) => {
let val = format!("{} {}", tag, n).trim().to_string();
let val = format!("{tag} {n}").trim().to_string();
Value::string(val, span)
}
serde_yaml::Value::Bool(b) => {
let val = format!("{} {}", tag, b).trim().to_string();
let val = format!("{tag} {b}").trim().to_string();
Value::string(val, span)
}
serde_yaml::Value::Null => {
let val = format!("{}", tag).trim().to_string();
let val = format!("{tag}").trim().to_string();
Value::string(val, span)
}
v => convert_yaml_value_to_nu_value(v, span, val_span)?,
};
value
}
}
serde_yaml::Value::Null => Value::nothing(span),
x => unimplemented!("Unsupported YAML case: {:?}", x),

View File

@ -50,7 +50,7 @@ fn make_unsupported_input_error(
) -> ShellError {
ShellError::UnsupportedInput {
msg: "expected table or record".to_string(),
input: format!("input type: {}", r#type),
input: format!("input type: {type}"),
msg_span: head,
input_span: span,
}

View File

@ -246,7 +246,7 @@ fn table(
escaped_rows.push(escaped_row);
}
let output_string = if (column_widths.is_empty() || column_widths.iter().all(|x| *x == 0))
if (column_widths.is_empty() || column_widths.iter().all(|x| *x == 0))
&& escaped_rows.is_empty()
{
String::from("")
@ -260,9 +260,7 @@ fn table(
)
.trim()
.to_string()
};
output_string
}
}
pub fn group_by(values: PipelineData, head: Span, config: &Config) -> (PipelineData, bool) {

View File

@ -210,8 +210,7 @@ impl Job {
from_type: "record".into(),
span: entry_span,
help: Some(format!(
"Invalid column \"{}\" in xml entry. Only \"{}\", \"{}\" and \"{}\" are permitted",
bad_column, COLUMN_TAG_NAME, COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME
"Invalid column \"{bad_column}\" in xml entry. Only \"{COLUMN_TAG_NAME}\", \"{COLUMN_ATTRS_NAME}\" and \"{COLUMN_CONTENT_NAME}\" are permitted"
)),
});
}
@ -399,7 +398,7 @@ impl Job {
});
}
let content_text = format!("{} {}", tag, content);
let content_text = format!("{tag} {content}");
// PI content must NOT be escaped
// https://www.w3.org/TR/xml/#sec-pi
let pi_content = BytesPI::new(content_text.as_str());
@ -428,8 +427,7 @@ impl Job {
from_type: Type::record().to_string(),
span: tag_span,
help: Some(format!(
"Incorrect tag name {}, tag name can not start with ! or ?",
tag
"Incorrect tag name {tag}, tag name can not start with ! or ?"
)),
});
}

View File

@ -211,7 +211,7 @@ fn parse_closure_result(
} else {
let error = ShellError::GenericError {
error: "Invalid block return".into(),
msg: format!("Unexpected record key '{}'", k),
msg: format!("Unexpected record key '{k}'"),
span: Some(span),
help: None,
inner: vec![],

View File

@ -144,7 +144,7 @@ fn build_help_commands(engine_state: &EngineState, span: Span) -> PipelineData {
for named_param in &sig.named {
let name = if let Some(short) = named_param.short {
if named_param.long.is_empty() {
format!("-{}", short)
format!("-{short}")
} else {
format!("--{}(-{})", named_param.long, short)
}

View File

@ -80,9 +80,9 @@ pub fn http_parse_url(
) -> Result<(String, Url), ShellError> {
let mut requested_url = raw_url.coerce_into_string()?;
if requested_url.starts_with(':') {
requested_url = format!("http://localhost{}", requested_url);
requested_url = format!("http://localhost{requested_url}");
} else if !requested_url.contains("://") {
requested_url = format!("http://{}", requested_url);
requested_url = format!("http://{requested_url}");
}
let url = match url::Url::parse(&requested_url) {
@ -382,8 +382,7 @@ fn send_multipart_request(
"Content-Type: application/octet-stream".to_string(),
"Content-Transfer-Encoding: binary".to_string(),
format!(
"Content-Disposition: form-data; name=\"{}\"; filename=\"{}\"",
col, col
"Content-Disposition: form-data; name=\"{col}\"; filename=\"{col}\""
),
format!("Content-Length: {}", val.len()),
];
@ -391,7 +390,7 @@ fn send_multipart_request(
.add(&mut Cursor::new(val), &headers.join("\r\n"))
.map_err(err)?;
} else {
let headers = format!(r#"Content-Disposition: form-data; name="{}""#, col);
let headers = format!(r#"Content-Disposition: form-data; name="{col}""#);
builder
.add(val.coerce_into_string()?.as_bytes(), &headers)
.map_err(err)?;
@ -400,7 +399,7 @@ fn send_multipart_request(
builder.finish();
let (boundary, data) = (builder.boundary, builder.data);
let content_type = format!("multipart/form-data; boundary={}", boundary);
let content_type = format!("multipart/form-data; boundary={boundary}");
move || req.set("Content-Type", &content_type).send_bytes(&data)
}
@ -703,26 +702,23 @@ fn transform_response_using_content_type(
.expect("Failed to parse content type, and failed to default to text/plain");
let ext = match (content_type.type_(), content_type.subtype()) {
(mime::TEXT, mime::PLAIN) => {
let path_extension = url::Url::parse(requested_url)
.map_err(|err| {
LabeledError::new(err.to_string())
.with_help("cannot parse")
.with_label(
format!("Cannot parse URL: {requested_url}"),
Span::unknown(),
)
})?
.path_segments()
.and_then(|mut segments| segments.next_back())
.and_then(|name| if name.is_empty() { None } else { Some(name) })
.and_then(|name| {
PathBuf::from(name)
.extension()
.map(|name| name.to_string_lossy().to_string())
});
path_extension
}
(mime::TEXT, mime::PLAIN) => url::Url::parse(requested_url)
.map_err(|err| {
LabeledError::new(err.to_string())
.with_help("cannot parse")
.with_label(
format!("Cannot parse URL: {requested_url}"),
Span::unknown(),
)
})?
.path_segments()
.and_then(|mut segments| segments.next_back())
.and_then(|name| if name.is_empty() { None } else { Some(name) })
.and_then(|name| {
PathBuf::from(name)
.extension()
.map(|name| name.to_string_lossy().to_string())
}),
_ => Some(content_type.subtype().to_string()),
};

View File

@ -64,7 +64,7 @@ impl Registry for NuShellNightly {
tag_name: String,
}
let url = format!("https://api.github.com/repos/{}/releases", pkg);
let url = format!("https://api.github.com/repos/{pkg}/releases");
let versions = http_client
.add_header("Accept", "application/vnd.github.v3+json")
.add_header("User-Agent", "update-informer")
@ -128,7 +128,7 @@ pub fn check_for_latest_nushell_version() -> Value {
if let Ok(Some(new_version)) = informer.check_version() {
rec.push("current", Value::test_bool(false));
rec.push("latest", Value::test_string(format!("{}", new_version)));
rec.push("latest", Value::test_string(format!("{new_version}")));
Value::test_record(rec)
} else {
rec.push("current", Value::test_bool(true));
@ -148,7 +148,7 @@ pub fn check_for_latest_nushell_version() -> Value {
if let Ok(Some(new_version)) = informer.check_version() {
rec.push("current", Value::test_bool(false));
rec.push("latest", Value::test_string(format!("{}", new_version)));
rec.push("latest", Value::test_string(format!("{new_version}")));
Value::test_record(rec)
} else {
rec.push("current", Value::test_bool(true));

View File

@ -208,7 +208,7 @@ impl EventTypeFilter {
fn wrong_type_error(head: Span, val: &str, val_span: Span) -> ShellError {
ShellError::UnsupportedInput {
msg: format!("{} is not a valid event type", val),
msg: format!("{val} is not a valid event type"),
input: "value originates from here".into(),
msg_span: head,
input_span: val_span,

View File

@ -135,8 +135,7 @@ fn uuid(
_ => {
return Err(ShellError::IncorrectValue {
msg: format!(
"Unsupported UUID version: {}. Supported versions are 1, 3, 4, 5, and 7.",
version
"Unsupported UUID version: {version}. Supported versions are 1, 3, 4, 5, and 7."
),
val_span: span,
call_span: span,
@ -190,8 +189,7 @@ fn validate_flags(
if v != 4 && v != 7 {
return Err(ShellError::IncorrectValue {
msg: format!(
"Unsupported UUID version: {}. Supported versions are 1, 3, 4, 5, and 7.",
v
"Unsupported UUID version: {v}. Supported versions are 1, 3, 4, 5, and 7."
),
val_span: span,
call_span: span,
@ -202,7 +200,7 @@ fn validate_flags(
.is_some()
{
return Err(ShellError::IncompatibleParametersSingle {
msg: format!("version {} uuid does not take mac as a parameter", v),
msg: format!("version {v} uuid does not take mac as a parameter"),
span,
});
}
@ -211,7 +209,7 @@ fn validate_flags(
.is_some()
{
return Err(ShellError::IncompatibleParametersSingle {
msg: format!("version {} uuid does not take namespace as a parameter", v),
msg: format!("version {v} uuid does not take namespace as a parameter"),
span,
});
}
@ -220,7 +218,7 @@ fn validate_flags(
.is_some()
{
return Err(ShellError::IncompatibleParametersSingle {
msg: format!("version {} uuid does not take name as a parameter", v),
msg: format!("version {v} uuid does not take name as a parameter"),
span,
});
}

View File

@ -81,33 +81,32 @@ fn process(
if let Ok(conn) = db.open_connection() {
match columns {
Some(record) => {
let mut create_stmt = format!("CREATE TABLE {} ( ", new_table_name);
let mut create_stmt = format!("CREATE TABLE {new_table_name} ( ");
for (column_name, column_datatype) in record {
match column_datatype.coerce_str()?.as_ref() {
"int" => {
create_stmt.push_str(&format!("{} INTEGER, ", column_name));
create_stmt.push_str(&format!("{column_name} INTEGER, "));
}
"float" => {
create_stmt.push_str(&format!("{} REAL, ", column_name));
create_stmt.push_str(&format!("{column_name} REAL, "));
}
"str" => {
create_stmt.push_str(&format!("{} VARCHAR(255), ", column_name));
create_stmt.push_str(&format!("{column_name} VARCHAR(255), "));
}
"bool" => {
create_stmt.push_str(&format!("{} BOOLEAN, ", column_name));
create_stmt.push_str(&format!("{column_name} BOOLEAN, "));
}
"datetime" => {
create_stmt.push_str(&format!(
"{} DATETIME DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), ",
column_name
"{column_name} DATETIME DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), "
));
}
_ => {
return Err(ShellError::UnsupportedInput {
msg: "unsupported column data type".into(),
input: format!("{:?}", column_datatype),
input: format!("{column_datatype:?}"),
msg_span: column_datatype.span(),
input_span: column_datatype.span(),
});

View File

@ -92,16 +92,16 @@ impl Command for StorDelete {
let sql_stmt = match where_clause_opt {
None => {
// We're deleting an entire table
format!("DROP TABLE {}", new_table_name)
format!("DROP TABLE {new_table_name}")
}
Some(where_clause) => {
// We're just deleting some rows
let mut delete_stmt = format!("DELETE FROM {} ", new_table_name);
let mut delete_stmt = format!("DELETE FROM {new_table_name} ");
// Yup, this is a bit janky, but I'm not sure a better way to do this without having
// --and and --or flags as well as supporting ==, !=, <>, is null, is not null, etc.
// and other sql syntax. So, for now, just type a sql where clause as a string.
delete_stmt.push_str(&format!("WHERE {}", where_clause));
delete_stmt.push_str(&format!("WHERE {where_clause}"));
delete_stmt
}
};

View File

@ -164,7 +164,7 @@ fn process(
}
let new_table_name = table_name.unwrap_or("table".into());
let mut create_stmt = format!("INSERT INTO {} (", new_table_name);
let mut create_stmt = format!("INSERT INTO {new_table_name} (");
let mut column_placeholders: Vec<String> = Vec::new();
let cols = record.columns();

View File

@ -164,7 +164,7 @@ fn process(
}
let new_table_name = table_name.unwrap_or("table".into());
if let Ok(conn) = db.open_connection() {
let mut update_stmt = format!("UPDATE {} ", new_table_name);
let mut update_stmt = format!("UPDATE {new_table_name} ");
update_stmt.push_str("SET ");
let mut placeholders: Vec<String> = Vec::new();

View File

@ -936,8 +936,7 @@ mod tests {
assert!(
duplicates.is_empty(),
"Duplicate short_names found: {:?}",
duplicates
"Duplicate short_names found: {duplicates:?}"
);
}
@ -958,8 +957,7 @@ mod tests {
assert!(
duplicates.is_empty(),
"Duplicate long_names found: {:?}",
duplicates
"Duplicate long_names found: {duplicates:?}"
);
}
}

View File

@ -155,9 +155,9 @@ fn format_value_impl(val: &Value, arg: &Arguments, span: Span) -> Value {
&arg.format_value.item
};
if d.fract() == 0.0 {
Value::string(format!("{} {}", d, unit), inner_span)
Value::string(format!("{d} {unit}"), inner_span)
} else {
Value::string(format!("{:.float_precision$} {}", d, unit), inner_span)
Value::string(format!("{d:.float_precision$} {unit}"), inner_span)
}
}
Err(e) => Value::error(e, inner_span),

View File

@ -103,7 +103,7 @@ fn run(
if first {
first = false;
} else if let Some(separator) = &separator {
write!(buffer, "{}", separator).map_err(&from_io_error)?;
write!(buffer, "{separator}").map_err(&from_io_error)?;
}
match value {

View File

@ -292,7 +292,7 @@ mod tests {
];
for expectation in &cases {
println!("{:?}", expectation);
println!("{expectation:?}");
let expected = expectation.expected;
let actual = action(
&word,

View File

@ -106,7 +106,7 @@ impl Command for NuCheck {
Err(err) => return Err(err),
};
let result = if as_module || path.is_dir() {
if as_module || path.is_dir() {
parse_file_or_dir_module(
path.to_string_lossy().as_bytes(),
&mut working_set,
@ -120,9 +120,7 @@ impl Command for NuCheck {
working_set.files = FileStack::with_file(path.clone());
parse_file_script(&path, &mut working_set, is_debug, path_span, call.head)
// The working set is not merged, so no need to pop the file from the stack.
};
result
}
} else {
Err(ShellError::GenericError {
error: "Failed to execute command".into(),

View File

@ -45,8 +45,8 @@ impl Command for UName {
os: false,
};
let output = uu_uname::UNameOutput::new(&opts).map_err(|e| ShellError::GenericError {
error: format!("{}", e),
msg: format!("{}", e),
error: format!("{e}"),
msg: format!("{e}"),
span: None,
help: None,
inner: Vec::new(),

View File

@ -379,7 +379,7 @@ fn get_theme_flag(
to_type: String::from("theme"),
from_type: String::from("string"),
span: call.span(),
help: Some(format!("{}, but found '{}'.", err, theme)),
help: Some(format!("{err}, but found '{theme}'.")),
})
})
.transpose()
@ -1117,7 +1117,7 @@ fn create_empty_placeholder(
return String::new();
}
let cell = format!("empty {}", value_type_name);
let cell = format!("empty {value_type_name}");
let mut table = NuTable::new(1, 1);
table.insert((0, 0), cell);
table.set_data_style(TextStyle::default().dimmed());
@ -1156,7 +1156,7 @@ fn convert_table_to_output(
} 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!")
};
Some(Ok(msg.as_bytes().to_vec()))

View File

@ -170,7 +170,7 @@ fn glob_files_in_parent(
let expected = expected
.join(" ")
.replace('/', std::path::MAIN_SEPARATOR_STR);
assert_eq!(actual.out, expected, "\n test: {}", tag);
assert_eq!(actual.out, expected, "\n test: {tag}");
});
}

View File

@ -70,7 +70,7 @@ fn into_int_binary_signed_empty() {
#[ignore]
fn into_int_datetime1() {
let dt = DateTime::parse_from_rfc3339("1983-04-13T12:09:14.123456789+00:00");
eprintln!("dt debug {:?}", dt);
eprintln!("dt debug {dt:?}");
assert_eq!(
dt,
Ok(FixedOffset::east_opt(0)

View File

@ -83,16 +83,13 @@ fn do_cases_where_result_is_same_between_join_types(join_type: &str) {
),
(("[{a: 1}]", "[{a: 1 b: 1}]", "a"), "[[a, b]; [1, 1]]"),
] {
let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on);
let expr = format!("{left} | join {right} {join_type} {on} | to nuon");
let actual = nu!(expr).out;
assert_eq!(actual, expected);
// Test again with streaming input (using `each` to convert the input into a ListStream)
let to_list_stream = "each { |i| $i } | ";
let expr = format!(
"{} | {} join {} {} {} | to nuon",
left, to_list_stream, right, join_type, on
);
let expr = format!("{left} | {to_list_stream} join {right} {join_type} {on} | to nuon");
let actual = nu!(expr).out;
assert_eq!(actual, expected);
}
@ -244,16 +241,14 @@ fn do_cases_where_result_differs_between_join_types(join_type: &str) {
] {
for (join_type_, expected) in join_types {
if join_type_ == join_type {
let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on);
let expr = format!("{left} | join {right} {join_type} {on} | to nuon");
let actual = nu!(expr).out;
assert_eq!(actual, expected);
// Test again with streaming input (using `each` to convert the input into a ListStream)
let to_list_stream = "each { |i| $i } | ";
let expr = format!(
"{} | {} join {} {} {} | to nuon",
left, to_list_stream, right, join_type, on
);
let expr =
format!("{left} | {to_list_stream} join {right} {join_type} {on} | to nuon");
let actual = nu!(expr).out;
assert_eq!(actual, expected);
}
@ -384,18 +379,15 @@ fn do_cases_where_result_differs_between_join_types_with_different_join_keys(joi
] {
for (join_type_, expected) in join_types {
if join_type_ == join_type {
let expr = format!(
"{} | join {} {} {} {} | to nuon",
left, right, join_type, left_on, right_on
);
let expr =
format!("{left} | join {right} {join_type} {left_on} {right_on} | to nuon");
let actual = nu!(expr).out;
assert_eq!(actual, expected);
// Test again with streaming input (using `each` to convert the input into a ListStream)
let to_list_stream = "each { |i| $i } | ";
let expr = format!(
"{} | {} join {} {} {} {} | to nuon",
left, to_list_stream, right, join_type, left_on, right_on
"{left} | {to_list_stream} join {right} {join_type} {left_on} {right_on} | to nuon"
);
let actual = nu!(expr).out;
assert_eq!(actual, expected);
@ -413,7 +405,7 @@ fn test_alternative_table_syntax() {
(("[[a]; [1]]", "[{a: 1}]", "a"), "[[a]; [1]]"),
(("[[a]; [1]]", "[[a]; [1]]", "a"), "[[a]; [1]]"),
] {
let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on);
let expr = format!("{left} | join {right} {join_type} {on} | to nuon");
let actual = nu!(&expr).out;
assert_eq!(actual, expected, "Expression was {}", &expr);
}

View File

@ -10,7 +10,7 @@ fn creates_temp_file() {
"mktemp"
);
let loc = AbsolutePath::try_new(&output.out).unwrap();
println!("{:?}", loc);
println!("{loc:?}");
assert!(loc.exists());
})
}

View File

@ -3698,11 +3698,10 @@ fn table_footer_inheritance() {
field0: [ [ y1, y2, y3 ]; [ 1 2 3 ] [ 79 79 79 ] [ {{ f1: 'a string', f2: 1000 }}, 1, 2 ] ],\
field1: [ a, b, c ],\
field2: [ 123, 234, 345 ],\
field3: {},\
field3: {table1},\
field4: {{ f1: 1, f2: 3, f3: {{ f1: f1, f2: f2, f3: f3 }} }},\
field5: [ [ x1, x2, x3 ]; [ 1 2 3 ] [ 79 79 79 ] [ {{ f1: 'a string', f2: 1000 }}, 1, 2 ] ],\
}}",
table1
}}"
);
let actual = nu!(format!(
"$env.config.table.footer_inheritance = true; {structure} | table --width=80 --expand"

View File

@ -24,7 +24,7 @@ fn row_but_all() {
#[test]
fn throw_inner_error() {
let error_msg = "This message should show up";
let error = format!("(error make {{ msg: \"{}\" }})", error_msg);
let error = format!("(error make {{ msg: \"{error_msg}\" }})");
let actual = nu!(format!(
"[[key value]; [foo 1] [foo 2] [{} 3]] | transpose",
error

View File

@ -540,10 +540,7 @@ fn change_file_times_to_date() {
assert!(
got_atime.signed_duration_since(expected).lt(&threshold)
&& got_mtime.signed_duration_since(expected).lt(&threshold),
"Expected: {}. Got: atime={}, mtime={}",
expected,
got_atime,
got_mtime
"Expected: {expected}. Got: atime={got_atime}, mtime={got_mtime}"
);
assert!(got_mtime.signed_duration_since(expected).lt(&threshold));
})

View File

@ -8,7 +8,7 @@ fn msgpack_test(fixture_name: &str, commands: Option<&str>) -> nu_test_support::
.join("generate.nu");
let mut outcome = None;
Playground::setup(&format!("msgpack test {}", fixture_name), |dirs, _| {
Playground::setup(&format!("msgpack test {fixture_name}"), |dirs, _| {
assert!(
nu!(
cwd: dirs.test(),