diff options
| author | Ralf Jung <post@ralfj.de> | 2022-12-02 18:16:08 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-12-02 18:16:08 +0100 |
| commit | b64d8670e4c512c29e6a58c73c0aba65f00bb800 (patch) | |
| tree | 8ab5152a8172f85f987a6e84fa1e088e7d67339a /compiler/rustc_errors/src | |
| parent | 80ab672b8611d34bf811d4498b9b9d116a085e7c (diff) | |
| parent | cef44f53034eac46be3a0e3eec7b2b3d4ef5140b (diff) | |
| download | rust-b64d8670e4c512c29e6a58c73c0aba65f00bb800.tar.gz rust-b64d8670e4c512c29e6a58c73c0aba65f00bb800.zip | |
Merge from rustc
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index bf20c7431e4..1fabe15ff83 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2282,7 +2282,7 @@ impl FileWithAnnotatedLines { } // Find overlapping multiline annotations, put them at different depths - multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, ml.line_end)); + multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, usize::MAX - ml.line_end)); for (_, ann) in multiline_annotations.clone() { for (_, a) in multiline_annotations.iter_mut() { // Move all other multiline annotations overlapping with this one @@ -2300,8 +2300,14 @@ impl FileWithAnnotatedLines { } let mut max_depth = 0; // max overlapping multiline spans - for (file, ann) in multiline_annotations { + for (_, ann) in &multiline_annotations { max_depth = max(max_depth, ann.depth); + } + // Change order of multispan depth to minimize the number of overlaps in the ASCII art. + for (_, a) in multiline_annotations.iter_mut() { + a.depth = max_depth - a.depth + 1; + } + for (file, ann) in multiline_annotations { let mut end_ann = ann.as_end(); if !ann.overlaps_exactly { // avoid output like |
