Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8280ae0

Browse files
authored
Merge pull request #231 from Muscraft/remove-message
Remove message
2 parents 11a8e92 + 99b68cb commit 8280ae0

34 files changed

+2018
-2255
lines changed

‎benches/bench.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ fn simple() -> String {
2424
_ => continue,
2525
}
2626
}"#;
27-
let message = Level::ERROR.header("mismatched types").id("E0308").group(
28-
Group::new().element(
27+
let message = &[Group::new()
28+
.element(Level::ERROR.title("mismatched types").id("E0308"))
29+
.element(
2930
Snippet::source(source)
3031
.line_start(51)
3132
.path("src/format.rs")
@@ -39,8 +40,7 @@ fn simple() -> String {
3940
.span(26..724)
4041
.label("expected enum `std::option::Option`"),
4142
),
42-
),
43-
);
43+
)];
4444

4545
let renderer = Renderer::plain();
4646
let rendered = renderer.render(message);
@@ -69,8 +69,9 @@ fn fold(bencher: divan::Bencher<'_, '_>, context: usize) {
6969
(input, span)
7070
})
7171
.bench_values(|(input, span)| {
72-
let message = Level::ERROR.header("mismatched types").id("E0308").group(
73-
Group::new().element(
72+
let message = &[Group::new()
73+
.element(Level::ERROR.title("mismatched types").id("E0308"))
74+
.element(
7475
Snippet::source(&input)
7576
.fold(true)
7677
.path("src/format.rs")
@@ -79,8 +80,7 @@ fn fold(bencher: divan::Bencher<'_, '_>, context: usize) {
7980
.span(span)
8081
.label("expected `Option<String>` because of return type"),
8182
),
82-
),
83-
);
83+
)];
8484

8585
let renderer = Renderer::plain();
8686
let rendered = renderer.render(message);

‎examples/custom_error.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@ fn main() {
1515
pub static C: u32 = 0 - 1;
1616
//~^ ERROR could not evaluate static initializer
1717
"#;
18-
let message = Level::ERROR
19-
.text(Some("error: internal compiler error"))
20-
.header("could not evaluate static initializer")
21-
.id("E0080")
22-
.group(
23-
Group::new().element(
24-
Snippet::source(source)
25-
.path("$DIR/err.rs")
26-
.fold(true)
27-
.annotation(
28-
AnnotationKind::Primary
29-
.span(386..391)
30-
.label("attempt to compute `0_u32 - 1_u32`, which would overflow"),
31-
),
32-
),
33-
);
18+
let message = &[Group::new()
19+
.element(
20+
Level::ERROR
21+
.text(Some("error: internal compiler error"))
22+
.title("could not evaluate static initializer")
23+
.id("E0080"),
24+
)
25+
.element(
26+
Snippet::source(source)
27+
.path("$DIR/err.rs")
28+
.fold(true)
29+
.annotation(
30+
AnnotationKind::Primary
31+
.span(386..391)
32+
.label("attempt to compute `0_u32 - 1_u32`, which would overflow"),
33+
),
34+
)];
3435

3536
let renderer = Renderer::styled().theme(OutputTheme::Unicode);
3637
anstream::println!("{}", renderer.render(message));

‎examples/custom_level.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ fn main() {
2929
}
3030
}
3131
"#;
32-
let message = Level::ERROR
33-
.header("`break` with value from a `while` loop")
34-
.id("E0571")
35-
.group(
36-
Group::new().element(
32+
let message = &[
33+
Group::new()
34+
.element(
35+
Level::ERROR
36+
.title("`break` with value from a `while` loop")
37+
.id("E0571"),
38+
)
39+
.element(
3740
Snippet::source(source)
3841
.line_start(1)
3942
.path("$DIR/issue-114529-illegal-break-with-value.rs")
@@ -49,22 +52,20 @@ fn main() {
4952
.label("you can't `break` with a value in a `while` loop"),
5053
),
5154
),
52-
)
53-
.group(
54-
Group::new()
55-
.element(
56-
Level::HELP
57-
.text(Some("suggestion"))
58-
.title("use `break` on its own without a value inside this `while` loop"),
59-
)
60-
.element(
61-
Snippet::source(source)
62-
.line_start(1)
63-
.path("$DIR/issue-114529-illegal-break-with-value.rs")
64-
.fold(true)
65-
.patch(Patch::new(483..581, "break")),
66-
),
67-
);
55+
Group::new()
56+
.element(
57+
Level::HELP
58+
.text(Some("suggestion"))
59+
.title("use `break` on its own without a value inside this `while` loop"),
60+
)
61+
.element(
62+
Snippet::source(source)
63+
.line_start(1)
64+
.path("$DIR/issue-114529-illegal-break-with-value.rs")
65+
.fold(true)
66+
.patch(Patch::new(483..581, "break")),
67+
),
68+
];
6869

6970
let renderer = Renderer::styled().theme(OutputTheme::Unicode);
7071
anstream::println!("{}", renderer.render(message));

‎examples/expected_type.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ fn main() {
66
,
77
range: <22, 25>,"#;
88
let message =
9-
Level::ERROR.header("expected type, found `22`").group(
10-
Group::new().element(
9+
&[Group::new()
10+
.element(Level::ERROR.title("expected type, found `22`"))
11+
.element(
1112
Snippet::source(source)
1213
.line_start(26)
1314
.path("examples/footer.rs")
@@ -20,8 +21,7 @@ fn main() {
2021
.span(34..50)
2122
.label("while parsing this struct"),
2223
),
23-
),
24-
);
24+
)];
2525

2626
let renderer = Renderer::styled();
2727
anstream::println!("{}", renderer.render(message));

‎examples/footer.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
use annotate_snippets::{AnnotationKind, Group, Level, Renderer, Snippet};
22

33
fn main() {
4-
let message = Level::ERROR
5-
.header("mismatched types")
6-
.id("E0308")
7-
.group(
8-
Group::new().element(
4+
let message = &[
5+
Group::new()
6+
.element(Level::ERROR.title("mismatched types").id("E0308"))
7+
.element(
98
Snippet::source(" slices: vec![\"A\",")
109
.line_start(13)
1110
.path("src/multislice.rs")
1211
.annotation(AnnotationKind::Primary.span(21..24).label(
1312
"expected struct `annotate_snippets::snippet::Slice`, found reference",
1413
)),
1514
),
16-
)
17-
.group(Group::new().element(Level::NOTE.title(
15+
Group::new().element(Level::NOTE.title(
1816
"expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`",
19-
)));
17+
)),
18+
];
2019

2120
let renderer = Renderer::styled();
2221
anstream::println!("{}", renderer.render(message));

‎examples/format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ fn main() {
2323
_ => continue,
2424
}
2525
}"#;
26-
let message = Level::ERROR.header("mismatched types").id("E0308").group(
27-
Group::new().element(
26+
let message = &[Group::new()
27+
.element(Level::ERROR.title("mismatched types").id("E0308"))
28+
.element(
2829
Snippet::source(source)
2930
.line_start(51)
3031
.path("src/format.rs")
@@ -38,8 +39,7 @@ fn main() {
3839
.span(26..724)
3940
.label("expected enum `std::option::Option`"),
4041
),
41-
),
42-
);
42+
)];
4343

4444
let renderer = Renderer::styled();
4545
anstream::println!("{}", renderer.render(message));

‎examples/highlight_source.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@ const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010
99
//~| ERROR cannot call non-const method
1010
fn main() {}
1111
"#;
12-
let message = Level::ERROR
13-
.header("allocations are not allowed in constants")
14-
.id("E0010")
15-
.group(
16-
Group::new()
17-
.element(
18-
Snippet::source(source)
19-
.fold(true)
20-
.path("$DIR/E0010-teach.rs")
21-
.annotation(
22-
AnnotationKind::Primary
23-
.span(72..85)
24-
.label("allocation not allowed in constants")
25-
.highlight_source(true),
26-
),
27-
)
28-
.element(
29-
Level::NOTE.title("The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created."),
12+
let message = &[Group::new().element(Level::ERROR.title("allocations are not allowed in constants")
13+
.id("E0010"))
14+
.element(
15+
Snippet::source(source)
16+
.fold(true)
17+
.path("$DIR/E0010-teach.rs")
18+
.annotation(
19+
AnnotationKind::Primary
20+
.span(72..85)
21+
.label("allocation not allowed in constants")
22+
.highlight_source(true),
3023
),
31-
);
24+
)
25+
.element(
26+
Level::NOTE.title("The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created."),
27+
28+
)];
3229

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

‎examples/highlight_title.rs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,35 @@ fn main() {
4141
magenta.render_reset()
4242
);
4343

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

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

‎examples/id_hyperlink.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ fn main() {
77
let () = 4; //~ ERROR
88
}
99
"#;
10-
let message = Level::ERROR
11-
.header("mismatched types")
12-
.id("E0308")
13-
.id_url("https://doc.rust-lang.org/error_codes/E0308.html")
14-
.group(
15-
Group::new().element(
16-
Snippet::source(source)
17-
.line_start(1)
18-
.path("$DIR/terminal_urls.rs")
19-
.fold(true)
20-
.annotation(
21-
AnnotationKind::Primary
22-
.span(59..61)
23-
.label("expected integer, found `()`"),
24-
)
25-
.annotation(
26-
AnnotationKind::Context
27-
.span(64..65)
28-
.label("this expression has type `{integer}`"),
29-
),
30-
),
31-
);
10+
let message = &[Group::new()
11+
.element(
12+
Level::ERROR
13+
.title("mismatched types")
14+
.id("E0308")
15+
.id_url("https://doc.rust-lang.org/error_codes/E0308.html"),
16+
)
17+
.element(
18+
Snippet::source(source)
19+
.line_start(1)
20+
.path("$DIR/terminal_urls.rs")
21+
.fold(true)
22+
.annotation(
23+
AnnotationKind::Primary
24+
.span(59..61)
25+
.label("expected integer, found `()`"),
26+
)
27+
.annotation(
28+
AnnotationKind::Context
29+
.span(64..65)
30+
.label("this expression has type `{integer}`"),
31+
),
32+
)];
3233

3334
let renderer = Renderer::styled().theme(OutputTheme::Unicode);
3435
anstream::println!("{}", renderer.render(message));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /