-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Replace usages of map_or(bool, ...)
with is_{some_and|none_or|ok_and}
#135738
Conversation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval Some changes occurred in coverage instrumentation. cc @Zalathar |
clippy --fix
for unnecessary_map_or
lintmap_or(bool, ...)
with is_{some_and|none_or|ok_and}
.iter() | ||
.find(|a| a.doc_str().is_some()) | ||
.map_or(true, |a| a.style() == ast::AttrStyle::Inner) | ||
attrs.iter().find(|a| a.doc_str().is_some()).is_none_or(|a| a.style() == ast::AttrStyle::Inner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic here could be simplified. is this not just attrs.iter().any(|a| a.doc_str().is_some() && a.style() == ast::AttrStyle::Inner)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err.. I don't think so, the original logic returns true if find()
returns None
. No?
Can't wrap my head right now around what's happening here, but I definitely agree it's not very readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. What the heck.
@compiler-errors my thought was to not do any manual cleanups, just let clippy do it's thing, but if I'm already doing some extra work on top of it I cleaned up a bunch of other stuff. |
@bors r+ rollup |
…compiler-errors Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}` Split out from rust-lang#135732 according to rust-lang#135732 , same thing but just for the compiler: > The usage of `map_or(bool, ...)` is really hard to understand IMHO. > This PR simply uses clippy (with `--fix`) to replace that with `is_{some_and|none_or|ok_and}`. > (no manual modifications were made, just machine applicable clippy fixes and then fmt) r? `@compiler-errors`
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#135310 (Always force non-trimming of path in `unreachable_patterns` lint) - rust-lang#135446 (further improve panic_immediate_abort by removing rtprintpanic! messages) - rust-lang#135491 (Remove dead rustc_allowed_through_unstable_modules for std::os::fd contents) - rust-lang#135542 (Add the concrete syntax for precise capturing to 1.82 release notes.) - rust-lang#135700 (Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy) - rust-lang#135729 (Add debug assertions to compiler profile) - rust-lang#135736 (rustdoc: Fix flaky doctest test) - rust-lang#135738 (Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang#135542 (Add the concrete syntax for precise capturing to 1.82 release notes.) - rust-lang#135700 (Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy) - rust-lang#135722 (make it possible to use ci-rustc on tarball sources) - rust-lang#135729 (Add debug assertions to compiler profile) - rust-lang#135736 (rustdoc: Fix flaky doctest test) - rust-lang#135738 (Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}`) - rust-lang#135747 (Rename FileName::QuoteExpansion to CfgSpec) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang#135542 (Add the concrete syntax for precise capturing to 1.82 release notes.) - rust-lang#135700 (Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy) - rust-lang#135722 (make it possible to use ci-rustc on tarball sources) - rust-lang#135729 (Add debug assertions to compiler profile) - rust-lang#135736 (rustdoc: Fix flaky doctest test) - rust-lang#135738 (Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}`) - rust-lang#135747 (Rename FileName::QuoteExpansion to CfgSpec) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang#135542 (Add the concrete syntax for precise capturing to 1.82 release notes.) - rust-lang#135700 (Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy) - rust-lang#135722 (make it possible to use ci-rustc on tarball sources) - rust-lang#135729 (Add debug assertions to compiler profile) - rust-lang#135736 (rustdoc: Fix flaky doctest test) - rust-lang#135738 (Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}`) - rust-lang#135747 (Rename FileName::QuoteExpansion to CfgSpec) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#135738 - yotamofek:map_or_true-compiler, r=compiler-errors Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}` Split out from rust-lang#135732 according to rust-lang#135732 , same thing but just for the compiler: > The usage of `map_or(bool, ...)` is really hard to understand IMHO. > This PR simply uses clippy (with `--fix`) to replace that with `is_{some_and|none_or|ok_and}`. > (no manual modifications were made, just machine applicable clippy fixes and then fmt) r? ``@compiler-errors``
Split out from #135732 according to #135732 ,
same thing but just for the compiler:
r? @compiler-errors