Skip to content

Commit

Permalink
Build fix attempt rust-lang#2.
Browse files Browse the repository at this point in the history
  • Loading branch information
ofeeg committed Apr 26, 2023
1 parent c5b5560 commit 412dfa6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions clippy_lints/src/methods/path_join_correction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ 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(),
applicability
);
}
);
}
}

0 comments on commit 412dfa6

Please sign in to comment.