Skip to content

Commit

Permalink
Move clippy::join_absolute_paths to clippy::suspicious
Browse files Browse the repository at this point in the history
  • Loading branch information
xFrednet committed Nov 10, 2023
1 parent 957cb2d commit b9433a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
24 changes: 12 additions & 12 deletions clippy_lints/src/methods/join_absolute_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, join_a
};

diag.note("joining a path starting with separator will replace the path instead")
.span_suggestion(
spanned.span,
"if this is unintentional, try removing the starting separator",
no_separator,
Applicability::Unspecified
)
.span_suggestion(
expr_span,
"if this is intentional, try creating a new Path instead",
format!("PathBuf::from({arg_str})"),
Applicability::Unspecified
);
.span_suggestion(
spanned.span,
"if this is unintentional, try removing the starting separator",
no_separator,
Applicability::Unspecified,
)
.span_suggestion(
expr_span,
"if this is intentional, try creating a new Path instead",
format!("PathBuf::from({arg_str})"),
Applicability::Unspecified,
);
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3719,7 +3719,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.75.0"]
pub JOIN_ABSOLUTE_PATHS,
correctness,
suspicious,
"calls to `Path::join` which will overwrite the original path"
}

Expand Down
1 change: 1 addition & 0 deletions tests/ui/join_absolute_paths.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LL | path.join("/sh");
|
= note: joining a path starting with separator will replace the path instead
= note: `-D clippy::join-absolute-paths` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::join_absolute_paths)]`
help: if this is unintentional, try removing the starting separator
|
LL | path.join("sh");
Expand Down

0 comments on commit b9433a6

Please sign in to comment.