Skip to content

Commit 958ae92

Browse files
author
Zibi Braniecki
committed
Update indentation to latest cargo fmt
1 parent 357f932 commit 958ae92

File tree

8 files changed

+254
-334
lines changed

8 files changed

+254
-334
lines changed

examples/expected_type.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,27 @@ fn main() {
1212
annotation_type: AnnotationType::Error,
1313
}),
1414
footer: vec![],
15-
slices: vec![
16-
Slice {
17-
source: r#" annotations: vec![SourceAnnotation {
15+
slices: vec![Slice {
16+
source: r#" annotations: vec![SourceAnnotation {
1817
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
1918
.to_string(),
2019
range: <22, 25>,"#.to_string(),
21-
line_start: 26,
22-
origin: Some("examples/footer.rs".to_string()),
23-
fold: true,
24-
annotations: vec![
25-
SourceAnnotation {
26-
label: "".to_string(),
27-
annotation_type: AnnotationType::Error,
28-
range: (208, 210),
29-
},
30-
SourceAnnotation {
31-
label: "while parsing this struct".to_string(),
32-
annotation_type: AnnotationType::Info,
33-
range: (34, 50),
34-
},
35-
],
36-
},
37-
],
20+
line_start: 26,
21+
origin: Some("examples/footer.rs".to_string()),
22+
fold: true,
23+
annotations: vec![
24+
SourceAnnotation {
25+
label: "".to_string(),
26+
annotation_type: AnnotationType::Error,
27+
range: (208, 210),
28+
},
29+
SourceAnnotation {
30+
label: "while parsing this struct".to_string(),
31+
annotation_type: AnnotationType::Info,
32+
range: (34, 50),
33+
},
34+
],
35+
}],
3836
};
3937

4038
let dl = DisplayList::from(snippet);

examples/footer.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,33 @@ use annotate_snippets::formatter::DisplayListFormatter;
55
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
66

77
fn main() {
8-
let snippet =
9-
Snippet {
10-
title: Some(Annotation {
11-
label: Some("mismatched types".to_string()),
12-
id: Some("E0308".to_string()),
13-
annotation_type: AnnotationType::Error,
14-
}),
15-
footer: vec![Annotation {
8+
let snippet = Snippet {
9+
title: Some(Annotation {
10+
label: Some("mismatched types".to_string()),
11+
id: Some("E0308".to_string()),
12+
annotation_type: AnnotationType::Error,
13+
}),
14+
footer: vec![Annotation {
1615
label: Some(
1716
"expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`"
1817
.to_string(),
1918
),
2019
id: None,
2120
annotation_type: AnnotationType::Note,
2221
}],
23-
slices: vec![
24-
Slice {
25-
source: " slices: vec![\"A\",".to_string(),
26-
line_start: 13,
27-
origin: Some("src/multislice.rs".to_string()),
28-
fold: false,
29-
annotations: vec![SourceAnnotation {
22+
slices: vec![Slice {
23+
source: " slices: vec![\"A\",".to_string(),
24+
line_start: 13,
25+
origin: Some("src/multislice.rs".to_string()),
26+
fold: false,
27+
annotations: vec![SourceAnnotation {
3028
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
3129
.to_string(),
3230
range: (21, 24),
3331
annotation_type: AnnotationType::Error,
3432
}],
35-
},
36-
],
37-
};
33+
}],
34+
};
3835

3936
let dl = DisplayList::from(snippet);
4037
let dlf = DisplayListFormatter::new(true);

examples/format.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, Sou
66

77
fn main() {
88
let snippet = Snippet {
9-
slices: vec![
10-
Slice {
11-
source: r#") -> Option<String> {
9+
slices: vec![Slice {
10+
source: r#") -> Option<String> {
1211
for ann in annotations {
1312
match (ann.range.0, ann.range.1) {
1413
(None, None) => continue,
@@ -30,23 +29,22 @@ fn main() {
3029
_ => continue,
3130
}
3231
}"#.to_string(),
33-
line_start: 51,
34-
origin: Some("src/format.rs".to_string()),
35-
fold: false,
36-
annotations: vec![
37-
SourceAnnotation {
38-
label: "expected `Option<String>` because of return type".to_string(),
39-
annotation_type: AnnotationType::Warning,
40-
range: (5, 19),
41-
},
42-
SourceAnnotation {
43-
label: "expected enum `std::option::Option`".to_string(),
44-
annotation_type: AnnotationType::Error,
45-
range: (23, 745),
46-
},
47-
],
48-
},
49-
],
32+
line_start: 51,
33+
origin: Some("src/format.rs".to_string()),
34+
fold: false,
35+
annotations: vec![
36+
SourceAnnotation {
37+
label: "expected `Option<String>` because of return type".to_string(),
38+
annotation_type: AnnotationType::Warning,
39+
range: (5, 19),
40+
},
41+
SourceAnnotation {
42+
label: "expected enum `std::option::Option`".to_string(),
43+
annotation_type: AnnotationType::Error,
44+
range: (23, 745),
45+
},
46+
],
47+
}],
5048
title: Some(Annotation {
5149
label: Some("mismatched types".to_string()),
5250
id: Some("E0308".to_string()),

src/display_list/from_snippet.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,12 @@ fn format_body(slice: &snippet::Slice, has_footer: bool) -> Vec<DisplayLine> {
308308
body_idx + 1,
309309
DisplayLine::Source {
310310
lineno: None,
311-
inline_marks: vec![
312-
DisplayMark {
313-
mark_type: DisplayMarkType::AnnotationThrough,
314-
annotation_type: DisplayAnnotationType::from(
315-
annotation.annotation_type,
316-
),
317-
},
318-
],
311+
inline_marks: vec![DisplayMark {
312+
mark_type: DisplayMarkType::AnnotationThrough,
313+
annotation_type: DisplayAnnotationType::from(
314+
annotation.annotation_type,
315+
),
316+
}],
319317
line: DisplaySourceLine::Annotation {
320318
annotation: Annotation {
321319
annotation_type,

src/formatter/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
pub mod style;
88

9-
use std::cmp;
10-
use display_list::*;
119
use self::style::{Style, StyleClass, Stylesheet};
10+
use display_list::*;
11+
use std::cmp;
1212

1313
#[cfg(feature = "ansi_term")]
1414
use stylesheets::color::AnsiTermStylesheet;

tests/dl_from_snippet.rs

+61-77
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ fn test_format_title() {
1515
slices: vec![],
1616
};
1717
let output = dl::DisplayList {
18-
body: vec![
19-
dl::DisplayLine::Raw(dl::DisplayRawLine::Annotation {
20-
annotation: dl::Annotation {
21-
annotation_type: dl::DisplayAnnotationType::Error,
22-
id: Some("E0001".to_string()),
23-
label: vec![
24-
dl::DisplayTextFragment {
25-
content: "This is a title".to_string(),
26-
style: dl::DisplayTextStyle::Emphasis,
27-
},
28-
],
29-
},
30-
source_aligned: false,
31-
continuation: false,
32-
}),
33-
],
18+
body: vec![dl::DisplayLine::Raw(dl::DisplayRawLine::Annotation {
19+
annotation: dl::Annotation {
20+
annotation_type: dl::DisplayAnnotationType::Error,
21+
id: Some("E0001".to_string()),
22+
label: vec![dl::DisplayTextFragment {
23+
content: "This is a title".to_string(),
24+
style: dl::DisplayTextStyle::Emphasis,
25+
}],
26+
},
27+
source_aligned: false,
28+
continuation: false,
29+
})],
3430
};
3531
assert_eq!(dl::DisplayList::from(input), output);
3632
}
@@ -40,15 +36,13 @@ fn test_format_slice() {
4036
let input = snippet::Snippet {
4137
title: None,
4238
footer: vec![],
43-
slices: vec![
44-
snippet::Slice {
45-
source: "This is line 1\nThis is line 2".to_string(),
46-
line_start: 5402,
47-
origin: None,
48-
annotations: vec![],
49-
fold: false,
50-
},
51-
],
39+
slices: vec![snippet::Slice {
40+
source: "This is line 1\nThis is line 2".to_string(),
41+
line_start: 5402,
42+
origin: None,
43+
annotations: vec![],
44+
fold: false,
45+
}],
5246
};
5347
let output = dl::DisplayList {
5448
body: vec![
@@ -163,21 +157,17 @@ fn test_format_slice_annotation_standalone() {
163157
let input = snippet::Snippet {
164158
title: None,
165159
footer: vec![],
166-
slices: vec![
167-
snippet::Slice {
168-
source: "This is line 1\nThis is line 2".to_string(),
169-
line_start: 5402,
170-
origin: None,
171-
annotations: vec![
172-
snippet::SourceAnnotation {
173-
range: (22, 24),
174-
label: "Test annotation".to_string(),
175-
annotation_type: snippet::AnnotationType::Info,
176-
},
177-
],
178-
fold: false,
179-
},
180-
],
160+
slices: vec![snippet::Slice {
161+
source: "This is line 1\nThis is line 2".to_string(),
162+
line_start: 5402,
163+
origin: None,
164+
annotations: vec![snippet::SourceAnnotation {
165+
range: (22, 24),
166+
label: "Test annotation".to_string(),
167+
annotation_type: snippet::AnnotationType::Info,
168+
}],
169+
fold: false,
170+
}],
181171
};
182172
let output = dl::DisplayList {
183173
body: vec![
@@ -209,12 +199,10 @@ fn test_format_slice_annotation_standalone() {
209199
annotation: dl::Annotation {
210200
annotation_type: dl::DisplayAnnotationType::Info,
211201
id: None,
212-
label: vec![
213-
dl::DisplayTextFragment {
214-
content: "Test annotation".to_string(),
215-
style: dl::DisplayTextStyle::Regular,
216-
},
217-
],
202+
label: vec![dl::DisplayTextFragment {
203+
content: "Test annotation".to_string(),
204+
style: dl::DisplayTextStyle::Regular,
205+
}],
218206
},
219207
range: (6, 8),
220208
annotation_type: dl::DisplayAnnotationType::Info,
@@ -235,40 +223,36 @@ fn test_format_slice_annotation_standalone() {
235223
fn test_format_label() {
236224
let input = snippet::Snippet {
237225
title: None,
238-
footer: vec![
239-
snippet::Annotation {
240-
id: None,
241-
label: Some("This __is__ a title".to_string()),
242-
annotation_type: snippet::AnnotationType::Error,
243-
},
244-
],
226+
footer: vec![snippet::Annotation {
227+
id: None,
228+
label: Some("This __is__ a title".to_string()),
229+
annotation_type: snippet::AnnotationType::Error,
230+
}],
245231
slices: vec![],
246232
};
247233
let output = dl::DisplayList {
248-
body: vec![
249-
dl::DisplayLine::Raw(dl::DisplayRawLine::Annotation {
250-
annotation: dl::Annotation {
251-
annotation_type: dl::DisplayAnnotationType::Error,
252-
id: None,
253-
label: vec![
254-
dl::DisplayTextFragment {
255-
content: "This ".to_string(),
256-
style: dl::DisplayTextStyle::Regular,
257-
},
258-
dl::DisplayTextFragment {
259-
content: "is".to_string(),
260-
style: dl::DisplayTextStyle::Emphasis,
261-
},
262-
dl::DisplayTextFragment {
263-
content: " a title".to_string(),
264-
style: dl::DisplayTextStyle::Regular,
265-
},
266-
],
267-
},
268-
source_aligned: true,
269-
continuation: false,
270-
}),
271-
],
234+
body: vec![dl::DisplayLine::Raw(dl::DisplayRawLine::Annotation {
235+
annotation: dl::Annotation {
236+
annotation_type: dl::DisplayAnnotationType::Error,
237+
id: None,
238+
label: vec![
239+
dl::DisplayTextFragment {
240+
content: "This ".to_string(),
241+
style: dl::DisplayTextStyle::Regular,
242+
},
243+
dl::DisplayTextFragment {
244+
content: "is".to_string(),
245+
style: dl::DisplayTextStyle::Emphasis,
246+
},
247+
dl::DisplayTextFragment {
248+
content: " a title".to_string(),
249+
style: dl::DisplayTextStyle::Regular,
250+
},
251+
],
252+
},
253+
source_aligned: true,
254+
continuation: false,
255+
})],
272256
};
273257
assert_eq!(dl::DisplayList::from(input), output);
274258
}

0 commit comments

Comments
 (0)