mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +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
@ -2160,12 +2160,10 @@ fn module_needs_reloading(working_set: &StateWorkingSet, module_id: ModuleId) ->
|
||||
return true;
|
||||
}
|
||||
|
||||
let private_submodule_changed = module
|
||||
module
|
||||
.imported_modules
|
||||
.iter()
|
||||
.any(|submodule_id| submodule_need_reloading(working_set, *submodule_id));
|
||||
|
||||
private_submodule_changed
|
||||
.any(|submodule_id| submodule_need_reloading(working_set, *submodule_id))
|
||||
}
|
||||
|
||||
/// Parse a module from a file.
|
||||
@ -4052,7 +4050,7 @@ pub fn parse_plugin_use(working_set: &mut StateWorkingSet, call: Box<Call>) -> P
|
||||
|
||||
pub fn find_dirs_var(working_set: &StateWorkingSet, var_name: &str) -> Option<VarId> {
|
||||
working_set
|
||||
.find_variable(format!("${}", var_name).as_bytes())
|
||||
.find_variable(format!("${var_name}").as_bytes())
|
||||
.filter(|var_id| working_set.get_variable(*var_id).const_val.is_some())
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ pub fn parse_shape_name(
|
||||
span: Span,
|
||||
use_loc: ShapeDescriptorUse,
|
||||
) -> SyntaxShape {
|
||||
let result = match bytes {
|
||||
match bytes {
|
||||
b"any" => SyntaxShape::Any,
|
||||
b"binary" => SyntaxShape::Binary,
|
||||
b"block" => {
|
||||
@ -106,20 +106,18 @@ pub fn parse_shape_name(
|
||||
}
|
||||
|
||||
if let Some(decl_id) = working_set.find_decl(cmd_name) {
|
||||
return SyntaxShape::CompleterWrapper(Box::new(shape), decl_id);
|
||||
SyntaxShape::CompleterWrapper(Box::new(shape), decl_id)
|
||||
} else {
|
||||
working_set.error(ParseError::UnknownCommand(cmd_span));
|
||||
return shape;
|
||||
shape
|
||||
}
|
||||
} else {
|
||||
//TODO: Handle error case for unknown shapes
|
||||
working_set.error(ParseError::UnknownType(span));
|
||||
return SyntaxShape::Any;
|
||||
SyntaxShape::Any
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_generic_shape(
|
||||
|
@ -1688,7 +1688,7 @@ pub fn parse_int(working_set: &mut StateWorkingSet, span: Span) -> Expression {
|
||||
Expression::new(working_set, Expr::Int(num), span, Type::Int)
|
||||
} else {
|
||||
working_set.error(ParseError::InvalidLiteral(
|
||||
format!("invalid digits for radix {}", radix),
|
||||
format!("invalid digits for radix {radix}"),
|
||||
"int".into(),
|
||||
span,
|
||||
));
|
||||
@ -3387,10 +3387,7 @@ pub fn parse_import_pattern(working_set: &mut StateWorkingSet, spans: &[Span]) -
|
||||
"list"
|
||||
};
|
||||
working_set.error(ParseError::WrongImportPattern(
|
||||
format!(
|
||||
"{} member can be only at the end of an import pattern",
|
||||
what
|
||||
),
|
||||
format!("{what} member can be only at the end of an import pattern"),
|
||||
prev_span,
|
||||
));
|
||||
return Expression::new(
|
||||
@ -6116,7 +6113,7 @@ fn check_record_key_or_value(
|
||||
let colon_position = i + string_value.span.start;
|
||||
ParseError::InvalidLiteral(
|
||||
"colon".to_string(),
|
||||
format!("bare word specifying record {}", position),
|
||||
format!("bare word specifying record {position}"),
|
||||
Span::new(colon_position, colon_position + 1),
|
||||
)
|
||||
})
|
||||
|
@ -24,7 +24,7 @@ fn test_int(
|
||||
|
||||
if let Some(err_pat) = expected_err {
|
||||
if let Some(parse_err) = err {
|
||||
let act_err = format!("{:?}", parse_err);
|
||||
let act_err = format!("{parse_err:?}");
|
||||
assert!(
|
||||
act_err.contains(err_pat),
|
||||
"{test_tag}: expected err to contain {err_pat}, but actual error was {act_err}"
|
||||
@ -2770,10 +2770,9 @@ mod input_types {
|
||||
|
||||
for prefix in ["let ", "mut ", "mut foo = 1; $"] {
|
||||
let input = format!(
|
||||
r#"{}foo = 1 |
|
||||
r#"{prefix}foo = 1 |
|
||||
# comment
|
||||
dummy"#,
|
||||
prefix
|
||||
dummy"#
|
||||
);
|
||||
let block = parse(&mut working_set, None, input.as_bytes(), true);
|
||||
let last_expr = &block.pipelines.last().unwrap().elements[0].expr.expr;
|
||||
@ -2783,11 +2782,11 @@ mod input_types {
|
||||
call.arguments[1].expr().unwrap()
|
||||
}
|
||||
Expr::BinaryOp(_, _, rhs) => rhs.as_ref(),
|
||||
_ => panic!("Unexpected expression: {:?}", last_expr),
|
||||
_ => panic!("Unexpected expression: {last_expr:?}"),
|
||||
};
|
||||
let block_id = match block_expr.expr {
|
||||
Expr::Block(block_id) | Expr::Subexpression(block_id) => block_id,
|
||||
_ => panic!("Unexpected expression: {:?}", block_expr),
|
||||
_ => panic!("Unexpected expression: {block_expr:?}"),
|
||||
};
|
||||
let rhs_expr = working_set.get_block(block_id);
|
||||
assert_eq!(rhs_expr.pipelines.len(), 1);
|
||||
|
Reference in New Issue
Block a user