diff options
| author | Isak Nyberg <36712644+IsakNyberg@users.noreply.github.com> | 2022-04-14 00:22:08 +0200 |
|---|---|---|
| committer | Isak Nyberg <36712644+IsakNyberg@users.noreply.github.com> | 2022-04-14 00:22:08 +0200 |
| commit | 53b2aca9da2af900bae32a4b7d389cf8fbbf6709 (patch) | |
| tree | 14607ae2ff40075c8171b98e5f9de2851993bd31 | |
| parent | dc4bfcbdfff651c82eff4bdd311d28e54d1513c4 (diff) | |
| download | rust-53b2aca9da2af900bae32a4b7d389cf8fbbf6709.tar.gz rust-53b2aca9da2af900bae32a4b7d389cf8fbbf6709.zip | |
Refactor loop into iterator; simplify negation logic.
| -rw-r--r-- | compiler/rustc_error_messages/src/lib.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index b33e6b66117..894f3fdaf59 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -320,18 +320,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.primary_spans.iter().all(|sp| sp.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 |
