mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 09:38:22 +02:00
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:
committed by
GitHub
parent
372d576846
commit
9da0f41ebb
@ -188,7 +188,7 @@ fn get_theme_from_asset_file(
|
||||
Some(t) => t,
|
||||
None => {
|
||||
return Err(ShellError::TypeMismatch {
|
||||
err_message: format!("Unknown HTML theme '{}'", theme_name),
|
||||
err_message: format!("Unknown HTML theme '{theme_name}'"),
|
||||
span: theme_span,
|
||||
});
|
||||
}
|
||||
@ -774,8 +774,7 @@ mod tests {
|
||||
for key in required_keys {
|
||||
assert!(
|
||||
theme_map.contains_key(key),
|
||||
"Expected theme to contain key '{}'",
|
||||
key
|
||||
"Expected theme to contain key '{key}'"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -792,15 +791,13 @@ mod tests {
|
||||
if let Err(err) = result {
|
||||
assert!(
|
||||
matches!(err, ShellError::TypeMismatch { .. }),
|
||||
"Expected TypeMismatch error, got: {:?}",
|
||||
err
|
||||
"Expected TypeMismatch error, got: {err:?}"
|
||||
);
|
||||
|
||||
if let ShellError::TypeMismatch { err_message, span } = err {
|
||||
assert!(
|
||||
err_message.contains("doesnt-exist"),
|
||||
"Error message should mention theme name, got: {}",
|
||||
err_message
|
||||
"Error message should mention theme name, got: {err_message}"
|
||||
);
|
||||
assert_eq!(span.start, 0);
|
||||
assert_eq!(span.end, 13);
|
||||
|
@ -161,28 +161,28 @@ fn convert_to_smallest_number_type(num: i64, span: Span) -> Value {
|
||||
let bytes = v.to_ne_bytes();
|
||||
let mut raw_string = "".to_string();
|
||||
for ch in bytes {
|
||||
raw_string.push_str(&format!("{:08b} ", ch));
|
||||
raw_string.push_str(&format!("{ch:08b} "));
|
||||
}
|
||||
Value::string(raw_string.trim(), span)
|
||||
} else if let Some(v) = num.to_i16() {
|
||||
let bytes = v.to_ne_bytes();
|
||||
let mut raw_string = "".to_string();
|
||||
for ch in bytes {
|
||||
raw_string.push_str(&format!("{:08b} ", ch));
|
||||
raw_string.push_str(&format!("{ch:08b} "));
|
||||
}
|
||||
Value::string(raw_string.trim(), span)
|
||||
} else if let Some(v) = num.to_i32() {
|
||||
let bytes = v.to_ne_bytes();
|
||||
let mut raw_string = "".to_string();
|
||||
for ch in bytes {
|
||||
raw_string.push_str(&format!("{:08b} ", ch));
|
||||
raw_string.push_str(&format!("{ch:08b} "));
|
||||
}
|
||||
Value::string(raw_string.trim(), span)
|
||||
} else {
|
||||
let bytes = num.to_ne_bytes();
|
||||
let mut raw_string = "".to_string();
|
||||
for ch in bytes {
|
||||
raw_string.push_str(&format!("{:08b} ", ch));
|
||||
raw_string.push_str(&format!("{ch:08b} "));
|
||||
}
|
||||
Value::string(raw_string.trim(), span)
|
||||
}
|
||||
@ -193,7 +193,7 @@ fn action(input: &Value, _args: &Arguments, span: Span) -> Value {
|
||||
Value::Binary { val, .. } => {
|
||||
let mut raw_string = "".to_string();
|
||||
for ch in val {
|
||||
raw_string.push_str(&format!("{:08b} ", ch));
|
||||
raw_string.push_str(&format!("{ch:08b} "));
|
||||
}
|
||||
Value::string(raw_string.trim(), span)
|
||||
}
|
||||
@ -204,7 +204,7 @@ fn action(input: &Value, _args: &Arguments, span: Span) -> Value {
|
||||
let raw_bytes = val.as_bytes();
|
||||
let mut raw_string = "".to_string();
|
||||
for ch in raw_bytes {
|
||||
raw_string.push_str(&format!("{:08b} ", ch));
|
||||
raw_string.push_str(&format!("{ch:08b} "));
|
||||
}
|
||||
Value::string(raw_string.trim(), span)
|
||||
}
|
||||
|
Reference in New Issue
Block a user