Skip to content

Commit 15bf02c

Browse files
committed
fmt
1 parent 21f2b6e commit 15bf02c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

clippy_lints/src/path_from_format.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ impl<'tcx> LateLintPass<'tcx> for PathFromFormat {
5656
let order_of_real_vars: Vec<usize> = format_args.formatters.iter().map(|(x, _)| *x).collect();
5757
let mut sugg = String::new();
5858
for n in 0..real_vars.len() {
59-
if (!string_parts[n].is_empty() && !(string_parts[n].ends_with('/') || string_parts[n].ends_with('\\'))) || (!string_parts[n+1].is_empty() && (!(string_parts[n+1].starts_with('/') || string_parts[n+1].starts_with('\\')))) {
59+
if (!string_parts[n].is_empty()
60+
&& !(string_parts[n].ends_with('/') || string_parts[n].ends_with('\\')))
61+
|| (!string_parts[n+1].is_empty()
62+
&& (!(string_parts[n+1].starts_with('/') || string_parts[n+1].starts_with('\\')))) {
6063
span_lint_and_note(
61-
cx,
62-
PATH_FROM_FORMAT,
63-
expr.span,
64-
"`format!(..)` used to form `PathBuf`",
65-
None,
66-
"if it fits your use case, you may want to consider using `Path::new()` and `.join()` to make it OS-agnostic and improve code readability.",
64+
cx,
65+
PATH_FROM_FORMAT,
66+
expr.span,
67+
"`format!(..)` used to form `PathBuf`",
68+
None,
69+
"if it fits your use case, you may want to consider using `Path::new()` and `.join()` to make it OS-agnostic and improve code readability.",
6770
);
6871
return;
6972
}
@@ -115,8 +118,7 @@ fn push_comps(string: &mut String, path: &Path) {
115118
let x = n.as_os_str().to_string_lossy().to_string();
116119
if string.is_empty() {
117120
string.push_str(&format!("Path::new(\"{x}\")"));
118-
}
119-
else {
121+
} else {
120122
string.push_str(&format!(".join(\"{x}\")"));
121123
}
122124
}

0 commit comments

Comments
 (0)