summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/path_buf_push_overwrite.txt
blob: 34f8901da2396d5a981816ade1656918d1a5f9cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
### What it does
* Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)
calls on `PathBuf` that can cause overwrites.

### Why is this bad?
Calling `push` with a root path at the start can overwrite the
previous defined path.

### Example
```
use std::path::PathBuf;

let mut x = PathBuf::from("/foo");
x.push("/bar");
assert_eq!(x, PathBuf::from("/bar"));
```
Could be written:

```
use std::path::PathBuf;

let mut x = PathBuf::from("/foo");
x.push("bar");
assert_eq!(x, PathBuf::from("/foo/bar"));
```