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

Enhance option_as_ref_deref lint with the |x| &**x case #5367

Closed
flip1995 opened this issue Mar 24, 2020 · 6 comments · Fixed by #5425
Closed

Enhance option_as_ref_deref lint with the |x| &**x case #5367

flip1995 opened this issue Mar 24, 2020 · 6 comments · Fixed by #5425
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@flip1995
Copy link
Member

In #4945, the option_as_ref_deref lint was added. This lint should be enhanced, so that it also detects:

opt.as_ref().map(|x| &**x)

Originally posted by @Areredify in #4945 (comment)

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Mar 24, 2020
@shepmaster
Copy link
Member

To be explicit, this should also probably cover opt.as_mut().map(|x| &mut **x).

@xiongmao86
Copy link
Contributor

If no one is working on this, I would like to take a stab.

@xiongmao86
Copy link
Contributor

I am trying to work on this, but I failed to open nightly rustc docs link in cheatsheet.

I search on bing.com but get nothing. Is it an intentional recent change or is it a temporary failure of something?

@shepmaster
Copy link
Member

I believe it was recently renamed. https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/

@xiongmao86
Copy link
Contributor

@shepmaster, thank you. Are there local version of this doc come with rustup doc?

@shepmaster
Copy link
Member

Are there local version of this doc

I don't know. rustup doc --path will show you the path of your documentation; you can look around in there to see if you can find it.

flip1995 added a commit to flip1995/rust-clippy that referenced this issue Apr 7, 2020
Ehance opt_as_ref_deref lint.

- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`

Lint on opt.as_ref().map(|x| &**x). Fixes rust-lang#5367.

changelog: lint on opt.as_ref().map(|x| &**x)
@bors bors closed this as completed in 79d1521 Apr 8, 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 good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants