Skip to content

Commit

Permalink
Rollup merge of #96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Refactor loop into iterator; simplify negation logic.

is_dummy should return when a non-dummy is found, but instead is iterated until completion. With some inspiration from line 323 this was refactored to a single line that returns once a single counterexample is found.
  • Loading branch information
Dylan-DPC authored Apr 19, 2022
2 parents a0ba15b + 657ae03 commit 113f079
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,12 @@ impl MultiSpan {

/// Returns `true` if any of the primary spans are displayable.
pub fn has_primary_spans(&self) -> bool {
self.primary_spans.iter().any(|sp| !sp.is_dummy())
!self.is_dummy()
}

/// Returns `true` if this contains only a dummy primary span with any hygienic context.
pub fn is_dummy(&self) -> bool {
let mut is_dummy = true;
for span in &self.primary_spans {
if !span.is_dummy() {
is_dummy = false;
}
}
is_dummy
self.primary_spans.iter().all(|sp| sp.is_dummy())
}

/// Replaces all occurrences of one Span with another. Used to move `Span`s in areas that don't
Expand Down

0 comments on commit 113f079

Please sign in to comment.