Skip to content

Suggest .as_ref()? instead of ? in certain circumstances. #3561

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

Merged
merged 7 commits into from
Dec 28, 2018
Merged

Suggest .as_ref()? instead of ? in certain circumstances. #3561

merged 7 commits into from
Dec 28, 2018

Conversation

fuerstenau
Copy link
Contributor

No description provided.

@fuerstenau
Copy link
Contributor Author

It works^{TM} but obviously should be sanity checked by someone who knows what they are doing. I'm not even capable of not confirming the pull request by some accidental button mashing before writing a description. (=

@flip1995 flip1995 added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 18, 2018
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

r=me with rustfmt run

@ghost
Copy link

ghost commented Dec 19, 2018

This change contains a bug. When the if expression contains an else branch but that doesn't match subject.

#![deny(clippy::all)]

pub fn func(x: Option<u32>) -> Option<u32> {

    let _ = if x.is_none() {
        return None;
    } else {
        //x
        Some(0)
    };

    Some(0)
}

fn main() {
}
error: this block may be rewritten with the `?` operator
  --> src/main.rs:12:13
   |
12 |       let _ = if x.is_none() {
   |  _____________^
13 | |         return None;
14 | |     } else {
15 | |         //x
16 | |         Some(0)
17 | |     };
   | |_____^ help: replace_it_with

@fuerstenau
Copy link
Contributor Author

Well the stupid “let's see if this lint should trigger but print out something in any case” bug should be fixed and even includes a test now to make it a bit harder to repeat my mistake.

The commata have been reinserted by hand.

@bors

This comment has been minimized.

@fuerstenau
Copy link
Contributor Author

@oli-obk GitHub still shows this as you having requested changes but it does not tell me which changes that should be. Could you either spell out the changes for me or tell me where to look them up?

@oli-obk
Copy link
Contributor

oli-obk commented Dec 28, 2018

It was just about the formatting failures. So everything is good now

@oli-obk
Copy link
Contributor

oli-obk commented Dec 28, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Dec 28, 2018

📌 Commit 8be7050 has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Dec 28, 2018

⌛ Testing commit 8be7050 with merge 3c4abb5...

bors added a commit that referenced this pull request Dec 28, 2018
Suggest `.as_ref()?` instead of `?` in certain circumstances.
@fuerstenau
Copy link
Contributor Author

That's what I had assumed based on your rather cryptic comment but after a week of trying to confirm my hypothesis without finding a way to do so I elected to ask you about it.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 28, 2018

I am very sorry about that. I should write my comments out. I'll do my best to do that in the future.

Please never hesitate to ask for clarification or anything else for that matter.

@bors
Copy link
Contributor

bors commented Dec 28, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 3c4abb5 to master...

@bors bors merged commit 8be7050 into rust-lang:master Dec 28, 2018
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants