Skip to content

Commit 37bb0c2

Browse files
committed
chore: Make AnnotateSnippetEmitter match revert of "all spans must be disjoint"
1 parent 457cbb0 commit 37bb0c2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,20 +329,22 @@ impl AnnotateSnippetEmitter {
329329
let substitutions = suggestion
330330
.substitutions
331331
.into_iter()
332-
.filter_map(|mut subst| {
332+
.filter(|subst| {
333333
// Suggestions coming from macros can have malformed spans. This is a heavy
334334
// handed approach to avoid ICEs by ignoring the suggestion outright.
335335
let invalid =
336336
subst.parts.iter().any(|item| sm.is_valid_span(item.span).is_err());
337337
if invalid {
338338
debug!("suggestion contains an invalid span: {:?}", subst);
339339
}
340-
340+
!invalid
341+
})
342+
.filter_map(|mut subst| {
341343
// Assumption: all spans are in the same file, and all spans
342344
// are disjoint. Sort in ascending order.
343345
subst.parts.sort_by_key(|part| part.span.lo());
344346
// Verify the assumption that all spans are disjoint
345-
assert_eq!(
347+
debug_assert_eq!(
346348
subst.parts.array_windows().find(|[a, b]| a.span.overlaps(b.span)),
347349
None,
348350
"all spans must be disjoint",
@@ -355,13 +357,11 @@ impl AnnotateSnippetEmitter {
355357

356358
let item_span = subst.parts.first()?;
357359
let file = sm.lookup_source_file(item_span.span.lo());
358-
if !invalid
359-
&& should_show_source_code(
360-
&self.ignored_directories_in_source_blocks,
361-
sm,
362-
&file,
363-
)
364-
{
360+
if should_show_source_code(
361+
&self.ignored_directories_in_source_blocks,
362+
sm,
363+
&file,
364+
) {
365365
Some(subst)
366366
} else {
367367
None

0 commit comments

Comments
 (0)