This commit is contained in:
Astro 2023-04-17 01:42:06 +02:00
parent be51621be5
commit 1f768bd4cf
5 changed files with 13 additions and 17 deletions

View File

@ -105,7 +105,7 @@ fn dead_to_edit(dead_code: DeadCode) -> Option<Edit> {
}
Scope::LambdaArg(name, _) => {
replacement = Some(format!("_{}", name));
replacement = Some(format!("_{name}"));
}
Scope::LetIn(let_in) => {

View File

@ -170,7 +170,7 @@ fn main() {
Err(error) => {
match output_format {
OutputFormat::HumanReadable => {
eprintln!("Error stating file {}: {}", path, error);
eprintln!("Error stating file {path}: {error}");
}
#[cfg(feature = "json-out")]
@ -179,7 +179,7 @@ fn main() {
json!({
"file": path,
"results": [{
"message": format!("{}", error),
"message": format!("{error}"),
}],
})
),
@ -195,7 +195,7 @@ fn main() {
Err(error) => {
match output_format {
OutputFormat::HumanReadable => {
eprintln!("Error reading file {}: {}", file, error);
eprintln!("Error reading file {file}: {error}");
}
#[cfg(feature = "json-out")]
@ -204,7 +204,7 @@ fn main() {
json!({
"file": file,
"results": [{
"message": format!("{}", error),
"message": format!("{error}"),
}],
})
),
@ -220,7 +220,7 @@ fn main() {
match output_format {
OutputFormat::HumanReadable => {
for error in errors {
eprintln!("Error parsing file {}: {}", file, error);
eprintln!("Error parsing file {file}: {error}");
}
}
@ -229,9 +229,9 @@ fn main() {
"{}",
json!({
"file": file,
"results": errors.into_iter()
"results": errors.iter()
.map(|error| json!({
"message": format!("{}", error),
"message": format!("{error}"),
}))
.collect::<Vec<_>>(),
})

View File

@ -45,7 +45,7 @@ pub fn print(file: String, content: &str, results: &[DeadCode]) {
// add report label
let mut label = Label::new((file.clone(), start_char..end_char))
.with_message(format!("{}", result))
.with_message(format!("{result}"))
.with_order(order as i32);
if !no_color {
label = label.with_color(result.scope.color());
@ -84,12 +84,12 @@ pub fn print_json(file: &str, content: &str, results: &[DeadCode]) {
line_offset = offset;
}
json!({
"message": format!("{}", result),
"message": format!("{result}"),
"line": line_number,
"column": start - line_offset + 1,
"endColumn": usize::from(range.end()) - line_offset + 1,
})
}).collect::<serde_json::Value>(),
});
println!("{}", json);
println!("{json}");
}

View File

@ -38,7 +38,7 @@ impl Scope {
match param {
Param::IdentParam(ident_param) => {
let name = ident_param.ident().expect("IdentParam.ident()");
Some(Scope::LambdaArg(name, body.clone()))
Some(Scope::LambdaArg(name, body))
}
Param::Pattern(pattern) => {
Some(Scope::LambdaPattern(pattern, body))

View File

@ -22,11 +22,7 @@ pub fn find(name: &Ident, node: &SyntaxNode<NixLanguage>) -> bool {
}
let ident = if node.kind() == SyntaxKind::NODE_IDENT {
if let Some(ident) = Ident::cast(node.clone()) {
Some(ident)
} else {
None
}
Ident::cast(node.clone())
} else {
None
};