}
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)> {
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