File tree 3 files changed +29
-3
lines changed
3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -3197,10 +3197,10 @@ declare_clippy_lint! {
3197
3197
3198
3198
declare_clippy_lint ! {
3199
3199
/// ### 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`.
3201
3201
///
3202
3202
/// ### 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.
3204
3204
/// If this is intentional, prefer creating a new `Path` instead.
3205
3205
///
3206
3206
/// 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
2
2
#![ allow( unused) ]
3
3
#![ warn( clippy:: join_absolute_path) ]
4
4
use std:: path:: Path ;
You can’t perform that action at this time.
0 commit comments