Rollup merge of #113084 - WaffleLapkin:less_map_or, r=Nilstrieb

Simplify some conditions

r? `@Nilstrieb`

Some things taken out of my `is_none_or` pr.
This commit is contained in:
Matthias Krüger 2023-06-27 22:10:15 +02:00 committed by GitHub
commit d505582ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 35 additions and 45 deletions

View file

@ -387,7 +387,7 @@ impl BasicCoverageBlockData {
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
// have an expression (to be injected into an existing `BasicBlock` represented by this
// `BasicCoverageBlock`).
if !self.counter_kind.as_ref().map_or(true, |c| c.is_expression()) {
if self.counter_kind.as_ref().is_some_and(|c| !c.is_expression()) {
return Error::from_string(format!(
"attempt to add an incoming edge counter from {:?} when the target BCB already \
has a `Counter`",

View file

@ -480,9 +480,10 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
fn check_invoked_macro_name_span(&mut self) {
if let Some(visible_macro) = self.curr().visible_macro(self.body_span) {
if self.prev_expn_span.map_or(true, |prev_expn_span| {
self.curr().expn_span.ctxt() != prev_expn_span.ctxt()
}) {
if !self
.prev_expn_span
.is_some_and(|prev_expn_span| self.curr().expn_span.ctxt() == prev_expn_span.ctxt())
{
let merged_prefix_len = self.curr_original_span.lo() - self.curr().span.lo();
let after_macro_bang =
merged_prefix_len + BytePos(visible_macro.as_str().len() as u32 + 1);