fix(needless_return_with_question_mark): skip when removing return ca…#17425
Conversation
|
Thanks for the pull request. A reviewer will take a look after it receives 2 community reviews. In the meantime, we would highly appreciate if you could try to review any of PRs waiting on community reviews. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
…uses a partial move error
036e250 to
b434b15
Compare
|
@rustbot ready |
|
It's not mainly about the scrutinee being inside an #![allow(clippy::single_match)]
fn main() -> Result<(), String> {
let v: Result<(), String> = Err("foo".to_string());
match v {
_whole @ Err(_) => {
Err("bar".to_string())?;
}
Ok(_) => {}
}
let _ = v.unwrap();
Ok(())
}but if I add a You should also fix dogfood errors. |
|
Reminder, once the PR becomes ready for a review, use |
|
@Gri-ffin In #17421 I mentioned that we couldn't add a ref to work around this because we we're calling a trait function on that owned value which was only implemented for the owned type (didn't implement |
I understand, I was just explaining the main issue and the problem with the current fix, and about the |
|
☔ The latest upstream changes (possibly #17369) made this pull request unmergeable. Please resolve the merge conflicts. |
changelog: [
needless_return_with_question_mark]: don't lint when removing the return would cause a partial move errorWhen the return is inside an if let that partially moves the scrutinee, and the scrutinee is used after the block, removing return breaks the borrow checker. This skips the lint in that case.
fixes #17421