From 326ec800b952749d0afc90be0604dc0332d70324 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 27 Mar 2019 19:26:47 -0700 Subject: Account for fully overlapping multiline annotations When two multiline span labels point at the same span, we special case the output to avoid weird behavior: ``` foo( _____^ |_____| || bar, || ); || ^ ||______| |______foo baz ``` instead showing ``` foo( _____^ | bar, | ); | ^ | | |______foo baz ``` --- src/libsyntax/test_snippet.rs | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index 2b3d18835d5..86910ffd894 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -374,6 +374,66 @@ error: foo "#); } +#[test] +fn triple_exact_overlap() { + test_harness(r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 +} +"#, + vec![ + SpanLabel { + start: Position { + string: "X0", + count: 1, + }, + end: Position { + string: "X2", + count: 1, + }, + label: "`X` is a good letter", + }, + SpanLabel { + start: Position { + string: "X0", + count: 1, + }, + end: Position { + string: "X2", + count: 1, + }, + label: "`Y` is a good letter too", + }, + SpanLabel { + start: Position { + string: "X0", + count: 1, + }, + end: Position { + string: "X2", + count: 1, + }, + label: "`Z` label", + }, + ], + r#" +error: foo + --> test.rs:3:3 + | +3 | / X0 Y0 Z0 +4 | | X1 Y1 Z1 +5 | | X2 Y2 Z2 + | | ^ + | | | + | | `X` is a good letter + | |____`Y` is a good letter too + | `Z` label + +"#); +} + #[test] fn minimum_depth() { test_harness(r#" -- cgit 1.4.1-3-g733a5