]> git.lizzy.rs Git - rust.git/commitdiff
Refactor loop into iterator; simplify negation logic.
authorIsak Nyberg <36712644+IsakNyberg@users.noreply.github.com>
Wed, 13 Apr 2022 22:22:08 +0000 (00:22 +0200)
committerIsak Nyberg <36712644+IsakNyberg@users.noreply.github.com>
Wed, 13 Apr 2022 22:22:08 +0000 (00:22 +0200)
compiler/rustc_error_messages/src/lib.rs

index b33e6b661170688ef21ac68fce8d549e5d34152c..894f3fdaf596d9b859d833274afd584eea603845 100644 (file)
@@ -320,18 +320,12 @@ pub fn primary_spans(&self) -> &[Span] {
 
     /// 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