diff --git a/clippy_lints/src/methods/path_join_correction.rs b/clippy_lints/src/methods/path_join_correction.rs index 7c245ad2ca2c..1be8e79e262c 100644 --- a/clippy_lints/src/methods/path_join_correction.rs +++ b/clippy_lints/src/methods/path_join_correction.rs @@ -9,17 +9,17 @@ use super::PATH_JOIN_CORRECTION; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, join_arg: &'tcx Expr<'tcx>, span: Span) { let ty = cx.typeck_results().expr_ty(expr); - if is_type_diagnostic_item(cx, ty, Path) { - let applicability = Applicability::MachineApplicable; - if_chain!( - if let ExprKind::Lit(spanned) = &join_arg.kind; - if let LitKind::Str(symbol, _) = spanned.node; - if symbol.as_str().starts_with('/') || symbol.as_str().starts_with('\\'); - then { - span_lint_and_sugg( - cx, - PATH_JOIN_CORRECTION, - span.with_hi(expr.span.hi()), + if_chain!( + if is_type_diagnostic_item(cx, ty, Path); + let applicability = Applicability::MachineApplicable; + if let ExprKind::Lit(spanned) = &join_arg.kind; + if let LitKind::Str(symbol, _) = spanned.node; + if symbol.as_str().starts_with('/') || symbol.as_str().starts_with('\\'); + then { + span_lint_and_sugg( + cx, + PATH_JOIN_CORRECTION, + span.with_hi(expr.span.hi()), r#"argument in join called on path contains a starting '/'"#, "try removing first '/' or '\\'", "join(\"your/path/here\")".to_owned(), @@ -27,5 +27,4 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, join_a ); } ); - } }