Skip to content

Commit

Permalink
join_absolute_paths: Address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
xFrednet committed Nov 19, 2023
1 parent b9433a6 commit f79f6ae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/join_absolute_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, join_a
&& let ExprKind::Lit(spanned) = expr_or_init(cx, join_arg).kind
&& let LitKind::Str(symbol, _) = spanned.node
&& let sym_str = symbol.as_str()
&& (sym_str.starts_with('/') || sym_str.starts_with('\\'))
&& sym_str.starts_with(&['/', '\\'])
{
span_lint_and_then(
cx,
Expand All @@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, join_a
)
.span_suggestion(
expr_span,
"if this is intentional, try creating a new Path instead",
"if this is intentional, try using `Path::new` 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 @@ -3694,7 +3694,7 @@ declare_clippy_lint! {
/// Note the behavior is platform dependent. A leading `\\` will be accepted
/// on unix systems as part of the file name
///
/// See [`Path::join()`](https://doc.rust-lang.org/std/path/struct.Path.html#method.join)
/// See [`Path::join`](https://doc.rust-lang.org/std/path/struct.Path.html#method.join)
///
/// ### Example
/// ```rust
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/join_absolute_paths.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ help: if this is unintentional, try removing the starting separator
|
LL | path.join("sh");
| ~~~~
help: if this is intentional, try creating a new Path instead
help: if this is intentional, try using `Path::new` instead
|
LL | PathBuf::from("/sh");
| ~~~~~~~~~~~~~~~~~~~~
Expand All @@ -27,7 +27,7 @@ help: if this is unintentional, try removing the starting separator
|
LL | path.join("\user");
| ~~~~~~~
help: if this is intentional, try creating a new Path instead
help: if this is intentional, try using `Path::new` instead
|
LL | PathBuf::from("\\user");
| ~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -43,7 +43,7 @@ help: if this is unintentional, try removing the starting separator
|
LL | path.join("sh");
| ~~~~
help: if this is intentional, try creating a new Path instead
help: if this is intentional, try using `Path::new` instead
|
LL | PathBuf::from("/sh");
| ~~~~~~~~~~~~~~~~~~~~
Expand All @@ -59,7 +59,7 @@ help: if this is unintentional, try removing the starting separator
|
LL | path.join(r#"sh"#);
| ~~~~~~~
help: if this is intentional, try creating a new Path instead
help: if this is intentional, try using `Path::new` instead
|
LL | PathBuf::from(r#"/sh"#);
| ~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit f79f6ae

Please sign in to comment.