@@ -4,12 +4,10 @@ extern crate criterion;
4
4
5
5
use criterion:: { black_box, Criterion } ;
6
6
7
- use annotate_snippets:: { Annotation , AnnotationType , Renderer , Slice , Snippet , SourceAnnotation } ;
7
+ use annotate_snippets:: { Label , Renderer , Slice , Snippet } ;
8
8
9
9
fn create_snippet ( renderer : Renderer ) {
10
- let snippet = Snippet {
11
- slices : vec ! [ Slice {
12
- source: r#") -> Option<String> {
10
+ let source = r#") -> Option<String> {
13
11
for ann in annotations {
14
12
match (ann.range.0, ann.range.1) {
15
13
(None, None) => continue,
@@ -30,30 +28,15 @@ fn create_snippet(renderer: Renderer) {
30
28
}
31
29
_ => continue,
32
30
}
33
- }"# ,
34
- line_start: 51 ,
35
- origin: Some ( "src/format.rs" ) ,
36
- fold: false ,
37
- annotations: vec![
38
- SourceAnnotation {
39
- label: "expected `Option<String>` because of return type" ,
40
- annotation_type: AnnotationType :: Warning ,
41
- range: 5 ..19 ,
42
- } ,
43
- SourceAnnotation {
44
- label: "expected enum `std::option::Option`" ,
45
- annotation_type: AnnotationType :: Error ,
46
- range: 26 ..724 ,
47
- } ,
48
- ] ,
49
- } ] ,
50
- title : Some ( Annotation {
51
- label : Some ( "mismatched types" ) ,
52
- id : Some ( "E0308" ) ,
53
- annotation_type : AnnotationType :: Error ,
54
- } ) ,
55
- footer : vec ! [ ] ,
56
- } ;
31
+ }"# ;
32
+ let snippet = Snippet :: error ( "mismatched types" ) . id ( "E0308" ) . slice (
33
+ Slice :: new ( source, 51 )
34
+ . origin ( "src/format.rs" )
35
+ . annotation (
36
+ Label :: warning ( "expected `Option<String>` because of return type" ) . span ( 5 ..19 ) ,
37
+ )
38
+ . annotation ( Label :: error ( "expected enum `std::option::Option`" ) . span ( 26 ..724 ) ) ,
39
+ ) ;
57
40
58
41
let _result = renderer. render ( snippet) . to_string ( ) ;
59
42
}
0 commit comments