Skip to content

Commit

Permalink
[path_buf_push_overwrite]: mark suggestion as MaybeIncorrect
Browse files Browse the repository at this point in the history
Proposing to replace

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

by

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

changes the content of `x` (`/bar` ⇒ `/foo/bar`).
  • Loading branch information
samueltardieu committed Jan 16, 2025
1 parent 8d0c0eb commit 3921ed6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/path_buf_push_overwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'t
"calling `push` with '/' or '\\' (file system root) will overwrite the previous path definition",
"try",
format!("\"{}\"", pushed_path_lit.trim_start_matches(['/', '\\'])),
Applicability::MachineApplicable,
Applicability::MaybeIncorrect,
);
}
}

0 comments on commit 3921ed6

Please sign in to comment.