Skip to content

Commit 9f44887

Browse files
committed
Applied cargo test supposed changes.
1 parent 5e6676c commit 9f44887

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

clippy_lints/src/methods/join_absolute_paths.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,19 @@ use super::JOIN_ABSOLUTE_PATHS;
1111

1212
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, join_arg: &'tcx Expr<'tcx>) {
1313
let ty = cx.typeck_results().expr_ty(expr).peel_refs();
14-
if !expr.span.from_expansion() {
15-
if is_type_diagnostic_item(cx, ty, Path) {
16-
let applicability = Applicability::MachineApplicable;
17-
if let ExprKind::Lit(spanned) = &join_arg.kind {
18-
if let LitKind::Str(symbol, _) = spanned.node {
19-
if symbol.as_str().starts_with('/') || symbol.as_str().starts_with('\\') {
20-
span_lint_and_sugg(
21-
cx,
22-
JOIN_ABSOLUTE_PATHS,
23-
join_arg.span().with_hi(expr.span.hi()),
24-
r#"argument to `Path::join` starts with a path separator"#,
25-
"try removing first '/' or '\\'",
26-
"join(\"your/path/here\")".to_owned(),
27-
applicability,
28-
);
29-
}
30-
}
31-
}
32-
}
14+
if !expr.span.from_expansion() && is_type_diagnostic_item(cx, ty, Path) {
15+
let applicability = Applicability::MachineApplicable;
16+
if let ExprKind::Lit(spanned) = &join_arg.kind && let LitKind::Str(symbol, _) = spanned.node
17+
&& (symbol.as_str().starts_with('/') || symbol.as_str().starts_with('\\')) {
18+
span_lint_and_sugg(
19+
cx,
20+
JOIN_ABSOLUTE_PATHS,
21+
join_arg.span().with_hi(expr.span.hi()),
22+
r#"argument to `Path::join` starts with a path separator"#,
23+
"try removing first '/' or '\\'",
24+
"join(\"your/path/here\")".to_owned(),
25+
applicability,
26+
);
27+
}
3328
};
3429
}

0 commit comments

Comments
 (0)