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 622b394

Browse files
authored
Merge pull request #275 from Muscraft/primary-secondary-title
Primary secondary title
2 parents 1a2fa7e + fc73e94 commit 622b394

37 files changed

+1019
-777
lines changed

‎benches/bench.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn simple() -> String {
2525
}
2626
}"#;
2727
let message = &[
28-
Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element(
28+
Group::with_title(Level::ERROR.primary_title("mismatched types").id("E0308")).element(
2929
Snippet::source(source)
3030
.line_start(51)
3131
.path("src/format.rs")
@@ -69,15 +69,17 @@ fn fold(bencher: divan::Bencher<'_, '_>, context: usize) {
6969
(input, span)
7070
})
7171
.bench_values(|(input, span)| {
72-
let message = &[
73-
Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element(
74-
Snippet::source(&input).path("src/format.rs").annotation(
75-
AnnotationKind::Context
76-
.span(span)
77-
.label("expected `Option<String>` because of return type"),
78-
),
79-
),
80-
];
72+
let message =
73+
&[
74+
Group::with_title(Level::ERROR.primary_title("mismatched types").id("E0308"))
75+
.element(
76+
Snippet::source(&input).path("src/format.rs").annotation(
77+
AnnotationKind::Context
78+
.span(span)
79+
.label("expected `Option<String>` because of return type"),
80+
),
81+
),
82+
];
8183

8284
let renderer = Renderer::plain();
8385
let rendered = renderer.render(message);

‎examples/custom_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub static C: u32 = 0 - 1;
1818
let message = &[Group::with_title(
1919
Level::ERROR
2020
.with_name(Some("error: internal compiler error"))
21-
.title("could not evaluate static initializer")
21+
.primary_title("could not evaluate static initializer")
2222
.id("E0080"),
2323
)
2424
.element(

‎examples/custom_level.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() {
3232
let message = &[
3333
Group::with_title(
3434
Level::ERROR
35-
.title("`break` with value from a `while` loop")
35+
.primary_title("`break` with value from a `while` loop")
3636
.id("E0571"),
3737
)
3838
.element(
@@ -53,7 +53,7 @@ fn main() {
5353
Group::with_title(
5454
Level::HELP
5555
.with_name(Some("suggestion"))
56-
.title("use `break` on its own without a value inside this `while` loop"),
56+
.primary_title("use `break` on its own without a value inside this `while` loop"),
5757
)
5858
.element(
5959
Snippet::source(source)

‎examples/expected_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
range: <22, 25>,"#;
88
let message =
99
&[
10-
Group::with_title(Level::ERROR.title("expected type, found `22`")).element(
10+
Group::with_title(Level::ERROR.primary_title("expected type, found `22`")).element(
1111
Snippet::source(source)
1212
.line_start(26)
1313
.path("examples/footer.rs")

‎examples/footer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use annotate_snippets::{AnnotationKind, Group, Level, Renderer, Snippet};
33
fn main() {
44
let message =
55
&[
6-
Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element(
6+
Group::with_title(Level::ERROR.primary_title("mismatched types").id("E0308")).element(
77
Snippet::source(" slices: vec![\"A\",")
88
.line_start(13)
99
.path("src/multislice.rs")
1010
.annotation(AnnotationKind::Primary.span(21..24).label(
1111
"expected struct `annotate_snippets::snippet::Slice`, found reference",
1212
)),
1313
),
14-
Group::with_title(Level::NOTE.title(
14+
Group::with_title(Level::NOTE.primary_title(
1515
"expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`",
1616
)),
1717
];

‎examples/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525
}"#;
2626
let message = &[
27-
Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element(
27+
Group::with_title(Level::ERROR.primary_title("mismatched types").id("E0308")).element(
2828
Snippet::source(source)
2929
.line_start(51)
3030
.path("src/format.rs")

‎examples/highlight_message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
);
3535

3636
let message = &[
37-
Group::with_title(Level::ERROR.title("mismatched types").id("E0308"))
37+
Group::with_title(Level::ERROR.primary_title("mismatched types").id("E0308"))
3838
.element(
3939
Snippet::source(source)
4040
.path("$DIR/highlighting.rs")
@@ -50,7 +50,7 @@ fn main() {
5050
),
5151
)
5252
.element(Level::NOTE.message(&message)),
53-
Group::with_title(Level::NOTE.title("function defined here")).element(
53+
Group::with_title(Level::NOTE.primary_title("function defined here")).element(
5454
Snippet::source(source)
5555
.path("$DIR/highlighting.rs")
5656
.annotation(AnnotationKind::Context.span(200..333).label(""))

‎examples/highlight_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010
99
//~| ERROR cannot call non-const method
1010
fn main() {}
1111
"#;
12-
let message = &[Group::with_title(Level::ERROR.title("allocations are not allowed in constants")
12+
let message = &[Group::with_title(Level::ERROR.primary_title("allocations are not allowed in constants")
1313
.id("E0010"))
1414
.element(
1515
Snippet::source(source)

‎examples/id_hyperlink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99
"#;
1010
let message = &[Group::with_title(
1111
Level::ERROR
12-
.title("mismatched types")
12+
.primary_title("mismatched types")
1313
.id("E0308")
1414
.id_url("https://doc.rust-lang.org/error_codes/E0308.html"),
1515
)

‎examples/multislice.rs

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

33
fn main() {
4-
let message = &[Group::with_title(Level::ERROR.title("mismatched types"))
5-
.element(
6-
Snippet::<Annotation<'_>>::source("Foo")
7-
.line_start(51)
8-
.fold(false)
9-
.path("src/format.rs"),
10-
)
11-
.element(
12-
Snippet::<Annotation<'_>>::source("Faa")
13-
.line_start(129)
14-
.fold(false)
15-
.path("src/display.rs"),
16-
)];
4+
let message = &[
5+
Group::with_title(Level::ERROR.primary_title("mismatched types"))
6+
.element(
7+
Snippet::<Annotation<'_>>::source("Foo")
8+
.line_start(51)
9+
.fold(false)
10+
.path("src/format.rs"),
11+
)
12+
.element(
13+
Snippet::<Annotation<'_>>::source("Faa")
14+
.line_start(129)
15+
.fold(false)
16+
.path("src/display.rs"),
17+
),
18+
];
1719

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

0 commit comments

Comments
(0)

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