[path_buf_push_overwrite]: mark suggestion as MaybeIncorrect (#14010)

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`). This is not equivalent
and should not be `MachineApplicable`, even if the original code is
suspicious.

changelog: none
This commit is contained in:
Catherine Flores 2025-02-07 12:27:35 +00:00 committed by GitHub
commit b5ea2491b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,
);
}
}