@@ -4,12 +4,10 @@ extern crate criterion;
44
55use criterion:: { black_box, Criterion } ;
66
7- use annotate_snippets:: { Annotation , AnnotationType , Renderer , Slice , Snippet , SourceAnnotation } ;
7+ use annotate_snippets:: { Label , Renderer , Slice , Snippet } ;
88
99fn create_snippet ( renderer : Renderer ) {
10- let snippet = Snippet {
11- slices : vec ! [ Slice {
12- source: r#") -> Option<String> {
10+ let source = r#") -> Option<String> {
1311 for ann in annotations {
1412 match (ann.range.0, ann.range.1) {
1513 (None, None) => continue,
@@ -30,30 +28,15 @@ fn create_snippet(renderer: Renderer) {
3028 }
3129 _ => continue,
3230 }
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+ ) ;
5740
5841 let _result = renderer. render ( snippet) . to_string ( ) ;
5942}
0 commit comments