-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
In this code
fn new(path: &std::path::PathBuf) {
let _ = path.clone().pop();
}
clippy will suggest to use Path
instead:
warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do.
--> src/main.rs:5:14
|
5 | fn new(path: &std::path::PathBuf) {
| ^^^^^^^^^^^^^^^^^^^ help: change this to: `&Path`
|
= note: `#[warn(clippy::ptr_arg)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
but this is wrong because Path
can't be .pop()
ed.
error[E0599]: no method named `pop` found for reference `&std::path::Path` in the current scope
--> src/main.rs:6:26
|
6 | let _ = path.clone().pop();
| ^^^ method not found in `&std::path::Path`
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have