Skip to content

Commit 86cc0e4

Browse files
committed
test: Update highlight_title to match rustc
1 parent f3b6eb8 commit 86cc0e4

File tree

2 files changed

+58
-27
lines changed

2 files changed

+58
-27
lines changed

examples/highlight_title.rs

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ fn main() {
55
let source = r#"// Make sure "highlighted" code is colored purple
66
77
//@ compile-flags: --error-format=human --color=always
8-
//@ error-pattern:for<'a> 
98
//@ edition:2018
109
1110
use core::pin::Pin;
@@ -24,8 +23,7 @@ fn wrapped_fn<'a>(_: Box<(dyn Any + Send)>) -> Pin<Box<(
2423
2524
fn main() {
2625
query(wrapped_fn);
27-
}
28-
"#;
26+
}"#;
2927

3028
let magenta = annotate_snippets::renderer::AnsiColor::Magenta
3129
.on_default()
@@ -43,25 +41,39 @@ fn main() {
4341
magenta.render_reset()
4442
);
4543

46-
let message = Level::ERROR.header("mismatched types").id("E0308").group(
47-
Group::new()
48-
.element(
49-
Snippet::source(source)
50-
.fold(true)
51-
.origin("$DIR/highlighting.rs")
52-
.annotation(
53-
AnnotationKind::Primary
54-
.span(589..599)
55-
.label("one type is more general than the other"),
56-
)
57-
.annotation(
58-
AnnotationKind::Context
59-
.span(583..588)
60-
.label("arguments to this function are incorrect"),
61-
),
62-
)
63-
.element(Level::NOTE.title(&title)),
64-
);
44+
let message = Level::ERROR
45+
.header("mismatched types")
46+
.id("E0308")
47+
.group(
48+
Group::new()
49+
.element(
50+
Snippet::source(source)
51+
.fold(true)
52+
.origin("$DIR/highlighting.rs")
53+
.annotation(
54+
AnnotationKind::Primary
55+
.span(553..563)
56+
.label("one type is more general than the other"),
57+
)
58+
.annotation(
59+
AnnotationKind::Context
60+
.span(547..552)
61+
.label("arguments to this function are incorrect"),
62+
),
63+
)
64+
.element(Level::NOTE.title(&title)),
65+
)
66+
.group(
67+
Group::new()
68+
.element(Level::NOTE.title("function defined here"))
69+
.element(
70+
Snippet::source(source)
71+
.fold(true)
72+
.origin("$DIR/highlighting.rs")
73+
.annotation(AnnotationKind::Context.span(200..333).label(""))
74+
.annotation(AnnotationKind::Primary.span(194..199)),
75+
),
76+
);
6577

6678
let renderer = Renderer::styled().anonymized_line_numbers(true);
6779
anstream::println!("{}", renderer.render(message));

examples/highlight_title.svg

Lines changed: 24 additions & 5 deletions
Loading

0 commit comments

Comments
 (0)