Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FN redundant_clone #5303

Closed
matthiaskrgr opened this issue Mar 11, 2020 · 0 comments · Fixed by #5304
Closed

FN redundant_clone #5303

matthiaskrgr opened this issue Mar 11, 2020 · 0 comments · Fixed by #5304
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-hard Call for participation: This a hard problem and requires more experience or effort to work on L-perf Lint: Belongs in the perf lint group

Comments

@matthiaskrgr
Copy link
Member

use std::path::PathBuf;

fn main() {
	let x = PathBuf::from("home");
	let y = x.clone().join("matthias"); 
        // join() creates a new owned pathbuf, does not take a &mut to x variable, thus the .clone() is redundant.(It also does not consume the PB)

	println!("x: {:?}, y: {:?}", x, y);
     // "x: "home", y: "home/matthias""
}

In this example let y = x.clone().join("matthias"); could just be let y = x.join("matthias");

@matthiaskrgr matthiaskrgr added the L-perf Lint: Belongs in the perf lint group label Mar 11, 2020
@flip1995 flip1995 added E-hard Call for participation: This a hard problem and requires more experience or effort to work on C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Mar 12, 2020
@bors bors closed this as completed in 8485d40 Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-hard Call for participation: This a hard problem and requires more experience or effort to work on L-perf Lint: Belongs in the perf lint group
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants