diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-11-28 15:42:10 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-28 15:42:10 +0530 |
| commit | 79fe15c8b0d76268a005cd1cc3c7caa42f481bcc (patch) | |
| tree | d4db27b5d5e8821e50e60be94979afd5ccb8bf75 /compiler/rustc_errors/src | |
| parent | f90484df8ad52f73c4f28cf3e4924c2bfa668a38 (diff) | |
| parent | 136ffa2ab1e4c1b8c1f30a775040b63f65b871da (diff) | |
| download | rust-79fe15c8b0d76268a005cd1cc3c7caa42f481bcc.tar.gz rust-79fe15c8b0d76268a005cd1cc3c7caa42f481bcc.zip | |
Rollup merge of #104795 - estebank:multiline-spans, r=TaKO8Ki
Change multiline span ASCII art visual order Tweak the ASCII art for nested multiline spans so that we minimize line overlaps. Partially addresses https://github.com/rust-lang/rust/issues/61017.
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 |
