diff options
| author | bors <bors@rust-lang.org> | 2022-05-30 14:59:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-30 14:59:12 +0000 |
| commit | e810f750a2a407f9caeabba39059578e844add14 (patch) | |
| tree | 3253be7f2752beafad84adaf246bc4e3f8f71c6d /compiler/rustc_errors/src | |
| parent | 946a88a989acdcc3b0d05a666eaac0db414ec2cd (diff) | |
| parent | a352ad500de8ba7c8cc71fbbe81da00b44f33ac2 (diff) | |
| download | rust-e810f750a2a407f9caeabba39059578e844add14.tar.gz rust-e810f750a2a407f9caeabba39059578e844add14.zip | |
Auto merge of #97548 - Dylan-DPC:rollup-9x0va1d, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #97494 (Use Box::new() instead of box syntax in library tests) - #97499 (Remove "sys isn't exported yet" phrase) - #97504 (Ensure source file present when calculating max line number) - #97519 (Re-add help_on_error for download-ci-llvm) - #97531 (Note pattern mismatch coming from `for` loop desugaring) - #97545 (Reword safety comments in core/hash/sip.rs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 5dd743e8d00..3fdc8cf8ac2 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1261,16 +1261,23 @@ impl EmitterWriter { return 0; }; + let will_be_emitted = |span: Span| { + !span.is_dummy() && { + let file = sm.lookup_source_file(span.hi()); + sm.ensure_source_file_source_present(file) + } + }; + let mut max = 0; for primary_span in msp.primary_spans() { - if !primary_span.is_dummy() { + if will_be_emitted(*primary_span) { let hi = sm.lookup_char_pos(primary_span.hi()); max = (hi.line).max(max); } } if !self.short_message { for span_label in msp.span_labels() { - if !span_label.span.is_dummy() { + if will_be_emitted(span_label.span) { let hi = sm.lookup_char_pos(span_label.span.hi()); max = (hi.line).max(max); } |
