File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -3197,10 +3197,10 @@ declare_clippy_lint! {
31973197
31983198declare_clippy_lint ! {
31993199 /// ### What it does
3200- /// Checks for initial `'/'` in an argument to `.join()` on a `Path`.
3200+ /// Checks for initial `'/ or \\ '` in an argument to `.join()` on a `Path`.
32013201 ///
32023202 /// ### Why is this bad?
3203- /// `.join()` comments starting with a separator, can replace the entire path.
3203+ /// `.join()` comments starting with a separator (`/` or `\\`) can replace the entire path.
32043204 /// If this is intentional, prefer creating a new `Path` instead.
32053205 ///
32063206 /// See [`Path::join()`](https://doc.rust-lang.org/std/path/struct.Path.html#method.join)
Original file line number Diff line number Diff line change 1+ //@run-rustfix
2+ #![allow(unused)]
3+ #![warn(clippy::join_absolute_path)]
4+ use std::path::Path;
5+
6+ fn main() {
7+ // should be linted
8+ let path = Path::new("/bin");
9+ path.join("/sh");
10+ println!("{}", path.display());
11+
12+ //should be linted
13+ let path = Path::new("C:\\Users");
14+ path.join("\\user");
15+ println!("{}", path.display());
16+
17+ // should not be linted
18+ let path: &[&str] = &["/bin"];
19+ path.join("/sh");
20+ println!("{:?}", path);
21+
22+ //should not be linted
23+ let path = Path::new("/bin");
24+ path.join("sh");
25+ println!("{}", path.display());
26+ }
Original file line number Diff line number Diff line change 1- // run-rustfix
1+ //@ run-rustfix
22#![ allow( unused) ]
33#![ warn( clippy:: join_absolute_path) ]
44use std:: path:: Path ;
You can’t perform that action at this time.
0 commit comments