]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_errors/lib.rs
Rollup merge of #68515 - Wind-River:master_2020, r=alexcrichton
[rust.git] / src / librustc_errors / lib.rs
index 889c84d6da1321ff582bd297f42219ebb3a37415..827e9b831f32d711978c1b0c960fc90aabc4ab49 100644 (file)
@@ -144,18 +144,6 @@ pub struct SubstitutionPart {
 }
 
 impl CodeSuggestion {
-    /// Suggestions coming from macros can have malformed spans. This is a heavy handed approach
-    /// to avoid ICEs by ignoring the suggestion outright.
-    pub fn has_valid_spans(&self, cm: &SourceMap) -> bool {
-        !self.substitutions.iter().any(|subst| {
-            let invalid = subst.parts.iter().any(|item| cm.is_valid_span(item.span).is_err());
-            if invalid {
-                debug!("malformed span in suggestion: {:?}", subst);
-            }
-            invalid
-        })
-    }
-
     /// Returns the assembled code suggestions, whether they should be shown with an underline
     /// and whether the substitution only differs in capitalization.
     pub fn splice_lines(&self, cm: &SourceMap) -> Vec<(String, Vec<SubstitutionPart>, bool)> {
@@ -187,6 +175,15 @@ fn push_trailing(
 
         self.substitutions
             .iter()
+            .filter(|subst| {
+                // Suggestions coming from macros can have malformed spans. This is a heavy
+                // handed approach to avoid ICEs by ignoring the suggestion outright.
+                let invalid = subst.parts.iter().any(|item| cm.is_valid_span(item.span).is_err());
+                if invalid {
+                    debug!("splice_lines: suggestion contains an invalid span: {:?}", subst);
+                }
+                !invalid
+            })
             .cloned()
             .map(|mut substitution| {
                 // Assumption: all spans are in the same file, and all spans