Skip to content

Commit 113f079

Browse files
authored
Rollup merge of rust-lang#96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC
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.
2 parents a0ba15b + 657ae03 commit 113f079

File tree

1 file changed

+2
-8
lines changed
  • compiler/rustc_error_messages/src

1 file changed

+2
-8
lines changed

compiler/rustc_error_messages/src/lib.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,12 @@ impl MultiSpan {
338338

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

344344
/// Returns `true` if this contains only a dummy primary span with any hygienic context.
345345
pub fn is_dummy(&self) -> bool {
346-
let mut is_dummy = true;
347-
for span in &self.primary_spans {
348-
if !span.is_dummy() {
349-
is_dummy = false;
350-
}
351-
}
352-
is_dummy
346+
self.primary_spans.iter().all(|sp| sp.is_dummy())
353347
}
354348

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

0 commit comments

Comments
 (0)