about summary refs log tree commit diff
path: root/src/librustdoc/scrape_examples.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-02 08:54:12 +0000
committerbors <bors@rust-lang.org>2024-10-02 08:54:12 +0000
commit398be8c8421f2a4013b3721dc4e2f3da0e87db41 (patch)
treeaccb94b5664d1867d3c0d7e35967196e0bfbbbff /src/librustdoc/scrape_examples.rs
parentd578f6ab0c89b9f556a3fd0f116a78613162cf4f (diff)
parent762a91b40e9f37f1b649f3a879e4639af32da2ed (diff)
downloadrust-398be8c8421f2a4013b3721dc4e2f3da0e87db41.tar.gz
rust-398be8c8421f2a4013b3721dc4e2f3da0e87db41.zip
Auto merge of #13443 - SpriteOvO:simplify-option-neg-methods, r=xFrednet
Simplify negative `Option::{is_some_and,is_none_or}`

Closes #13436.

Improved based on the existing lint `nonminimal_bool`, since there is already handling of similar methods `Option::{is_some,is_none}` and `Result::{is_ok,is_err}`, and there is a lot of reusable code.

When `is_some_and` or `is_none_or` have a negation, we invert it into another method by removing the Not sign and inverting the expression in the closure.

For the case where the closure block has statements, currently no simplification is implemented. (Should we do it?)

```rust
// Currently will not simplify this
_ = !opt.is_some_and(|x| {
    let complex_block = 100;
    x == complex_block
});
```

changelog: [`nonminimal_bool`]: Simplify negative `Option::{is_some_and,is_none_or}`
Diffstat (limited to 'src/librustdoc/scrape_examples.rs')
0 files changed, 0 insertions, 0 deletions