Skip to content

Commit 4c1b25a

Browse files
committed
Entered supposed changes, ran cargo dev fmt, test, and bless.
1 parent b91f9e0 commit 4c1b25a

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

clippy_lints/src/methods/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3197,10 +3197,10 @@ declare_clippy_lint! {
31973197

31983198
declare_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)

tests/ui/join_absolute_path.fixed

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}

tests/ui/join_absolute_path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// run-rustfix
1+
//@run-rustfix
22
#![allow(unused)]
33
#![warn(clippy::join_absolute_path)]
44
use std::path::Path;

0 commit comments

Comments
 (0)