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

Lint for Unnecessary Map #1005

Closed
mmstick opened this issue Jun 12, 2016 · 3 comments
Closed

Lint for Unnecessary Map #1005

mmstick opened this issue Jun 12, 2016 · 3 comments
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-unnecessary Lint: Warn about unnecessary code T-middle Type: Probably requires verifiying types

Comments

@mmstick
Copy link

mmstick commented Jun 12, 2016

It woud be nice if clippy could detect situations where map() is being used unnecessarily to pass a contained value wrapped as either a Result or an Option.

Unnecessarry

let mut file = File::open(path)
         .map(|file| file)
         .unwrap_or_else(|why| panic!("couldn't open {}: {}", infilename, why));

Recommended

let mut file = File::open(infilename)
         .unwrap_or_else(|why| panic!("couldn't open {}: {}", infilename, why));
@Manishearth Manishearth added good-first-issue These issues are a good way to get started with Clippy T-middle Type: Probably requires verifiying types A-lint Area: New lints L-unnecessary Lint: Warn about unnecessary code labels Jun 12, 2016
@shepmaster
Copy link
Member

wrapped as either a Result or an Option.

Wouldn't this apply for wider uses of map, such as on an iterator?

@mmstick
Copy link
Author

mmstick commented Jun 13, 2016

Wouldn't this apply for wider uses of map, such as on an iterator?

I suppose it would also apply for using map(|x| x) uselessly on an Iterator too.

@camsteffen
Copy link
Contributor

Resolved by #5694

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-unnecessary Lint: Warn about unnecessary code T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

4 participants