diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-30 14:33:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-30 14:33:50 +0200 |
| commit | 106d5fde92f210b9a1728a54b9ce76ad52641b40 (patch) | |
| tree | ac39dbd4e01f601c28f57195e049bd463e686aa4 /compiler/rustc_errors/src | |
| parent | 8fd9e24b9a7660fae2f10090e3063808d70afc97 (diff) | |
| parent | 5a4e9363a3fe142d5c7ea7acb8c61985fe34e704 (diff) | |
| download | rust-106d5fde92f210b9a1728a54b9ce76ad52641b40.tar.gz rust-106d5fde92f210b9a1728a54b9ce76ad52641b40.zip | |
Rollup merge of #97504 - JohnTitor:cleanup-deps, r=davidtwco
Ensure source file present when calculating max line number Resubmission of #89268, fixes #71363 The behavior difference of `simulate-remapped-rust-src-base` is not something we should take into account here, so limiting targets to run the test makes sense, I think. r? `@davidtwco,` and `@estebank,` you might be interested in this change
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); } |
