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

@ -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));
})