diff --git a/benches/bench.rs b/benches/bench.rs index 4e03ae8..2adcc18 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -71,14 +71,11 @@ fn fold(bencher: divan::Bencher<'_, '_>, context: usize) { .bench_values(|(input, span)| { let message = &[ Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element( - Snippet::source(&input) - .fold(true) - .path("src/format.rs") - .annotation( - AnnotationKind::Context - .span(span) - .label("expected `Option` because of return type"), - ), + Snippet::source(&input).path("src/format.rs").annotation( + AnnotationKind::Context + .span(span) + .label("expected `Option` because of return type"), + ), ), ]; diff --git a/examples/custom_error.rs b/examples/custom_error.rs index a26dc4a..76ae0cc 100644 --- a/examples/custom_error.rs +++ b/examples/custom_error.rs @@ -22,14 +22,11 @@ pub static C: u32 = 0 - 1; .id("E0080"), ) .element( - Snippet::source(source) - .path("$DIR/err.rs") - .fold(true) - .annotation( - AnnotationKind::Primary - .span(386..391) - .label("attempt to compute `0_u32 - 1_u32`, which would overflow"), - ), + Snippet::source(source).path("$DIR/err.rs").annotation( + AnnotationKind::Primary + .span(386..391) + .label("attempt to compute `0_u32 - 1_u32`, which would overflow"), + ), )]; let renderer = Renderer::styled().theme(OutputTheme::Unicode); diff --git a/examples/custom_level.rs b/examples/custom_level.rs index 3cf475d..41e8322 100644 --- a/examples/custom_level.rs +++ b/examples/custom_level.rs @@ -39,7 +39,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/issue-114529-illegal-break-with-value.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(483..581) @@ -60,7 +59,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/issue-114529-illegal-break-with-value.rs") - .fold(true) .patch(Patch::new(483..581, "break")), ), ]; diff --git a/examples/expected_type.rs b/examples/expected_type.rs index 6bbf081..37120b3 100644 --- a/examples/expected_type.rs +++ b/examples/expected_type.rs @@ -11,7 +11,6 @@ fn main() { Snippet::source(source) .line_start(26) .path("examples/footer.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(193..195).label( "expected struct `annotate_snippets::snippet::Slice`, found reference", )) diff --git a/examples/format.rs b/examples/format.rs index 384453b..5f9bad3 100644 --- a/examples/format.rs +++ b/examples/format.rs @@ -28,6 +28,7 @@ fn main() { Snippet::source(source) .line_start(51) .path("src/format.rs") + .fold(false) .annotation( AnnotationKind::Context .span(5..19) diff --git a/examples/highlight_source.rs b/examples/highlight_source.rs index 297ad87..22ab0d6 100644 --- a/examples/highlight_source.rs +++ b/examples/highlight_source.rs @@ -13,7 +13,6 @@ fn main() {} .id("E0010")) .element( Snippet::source(source) - .fold(true) .path("$DIR/E0010-teach.rs") .annotation( AnnotationKind::Primary diff --git a/examples/highlight_title.rs b/examples/highlight_title.rs index 7f6ccb7..1de99cf 100644 --- a/examples/highlight_title.rs +++ b/examples/highlight_title.rs @@ -45,7 +45,6 @@ fn main() { Group::with_title(Level::ERROR.title("mismatched types").id("E0308")) .element( Snippet::source(source) - .fold(true) .path("$DIR/highlighting.rs") .annotation( AnnotationKind::Primary @@ -61,7 +60,6 @@ fn main() { .element(Level::NOTE.pre_styled_title(&title)), Group::with_title(Level::NOTE.title("function defined here")).element( Snippet::source(source) - .fold(true) .path("$DIR/highlighting.rs") .annotation(AnnotationKind::Context.span(200..333).label("")) .annotation(AnnotationKind::Primary.span(194..199)), diff --git a/examples/id_hyperlink.rs b/examples/id_hyperlink.rs index 6259e4d..9070b26 100644 --- a/examples/id_hyperlink.rs +++ b/examples/id_hyperlink.rs @@ -17,7 +17,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/terminal_urls.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(59..61) diff --git a/examples/multislice.rs b/examples/multislice.rs index 35b745c..c494afa 100644 --- a/examples/multislice.rs +++ b/examples/multislice.rs @@ -5,11 +5,13 @@ fn main() { .element( Snippet::>::source("Foo") .line_start(51) + .fold(false) .path("src/format.rs"), ) .element( Snippet::>::source("Faa") .line_start(129) + .fold(false) .path("src/display.rs"), )]; diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index fe29822..65035c3 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -29,7 +29,6 @@ //! Snippet::source(source) //! .path("temp.rs") //! .line_start(1) -//! .fold(true) //! .annotation( //! AnnotationKind::Primary //! .span(10..13) diff --git a/src/snippet.rs b/src/snippet.rs index 851a55f..1b317d7 100644 --- a/src/snippet.rs +++ b/src/snippet.rs @@ -168,7 +168,7 @@ impl<'a, T: Clone> Snippet<'a, T> { line_start: 1, source: source.into(), markers: vec![], - fold: false, + fold: true, } } diff --git a/tests/color/fold_ann_multiline.rs b/tests/color/fold_ann_multiline.rs index 68fd4f1..5115b95 100644 --- a/tests/color/fold_ann_multiline.rs +++ b/tests/color/fold_ann_multiline.rs @@ -33,7 +33,6 @@ fn case() { Snippet::source(source) .path("src/format.rs") .line_start(51) - .fold(true) .annotation(AnnotationKind::Context.span(5..19).label( "expected `std::option::Option` because of return type", )) diff --git a/tests/color/fold_bad_origin_line.rs b/tests/color/fold_bad_origin_line.rs index 99da3c5..1a04adb 100644 --- a/tests/color/fold_bad_origin_line.rs +++ b/tests/color/fold_bad_origin_line.rs @@ -13,7 +13,6 @@ invalid syntax Snippet::source(source) .path("path/to/error.rs") .line_start(1) - .fold(true) .annotation(AnnotationKind::Context.span(2..16).label("error here")), )]; let expected = file!["fold_bad_origin_line.term.svg"]; diff --git a/tests/color/fold_leading.rs b/tests/color/fold_leading.rs index e941c80..f4d29e3 100644 --- a/tests/color/fold_leading.rs +++ b/tests/color/fold_leading.rs @@ -26,7 +26,6 @@ workspace = 20 Snippet::source(source) .path("Cargo.toml") .line_start(1) - .fold(true) .annotation(AnnotationKind::Primary.span(132..134).label("")), )]; let expected = file!["fold_leading.term.svg"]; diff --git a/tests/color/fold_trailing.rs b/tests/color/fold_trailing.rs index 9c85d87..59455c0 100644 --- a/tests/color/fold_trailing.rs +++ b/tests/color/fold_trailing.rs @@ -25,7 +25,6 @@ edition = "2021" Snippet::source(source) .path("Cargo.toml") .line_start(1) - .fold(true) .annotation(AnnotationKind::Primary.span(8..10).label("")), )]; let expected = file!["fold_trailing.term.svg"]; diff --git a/tests/color/multiline_removal_suggestion.rs b/tests/color/multiline_removal_suggestion.rs index 6a98ec4..8559ee9 100644 --- a/tests/color/multiline_removal_suggestion.rs +++ b/tests/color/multiline_removal_suggestion.rs @@ -73,7 +73,6 @@ fn main() {} .element( Snippet::source(source) .path("$DIR/multiline-removal-suggestion.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(769..776) @@ -96,7 +95,7 @@ fn main() {} Group::with_title(Level::HELP.title("consider removing this method call, as the receiver has type `std::vec::IntoIter>` and `std::vec::IntoIter>: Iterator` trivially holds")).element( Snippet::source(source) .path("$DIR/multiline-removal-suggestion.rs") - .fold(true) + .patch(Patch::new(708..768, "")), ), ]; diff --git a/tests/color/multiple_annotations.rs b/tests/color/multiple_annotations.rs index 4533019..a92c72f 100644 --- a/tests/color/multiple_annotations.rs +++ b/tests/color/multiple_annotations.rs @@ -18,6 +18,7 @@ fn case() { let input = &[Group::with_title(Level::ERROR.title("")).element( Snippet::source(source) .line_start(96) + .fold(false) .annotation( AnnotationKind::Primary .span(100..110) diff --git a/tests/formatter.rs b/tests/formatter.rs index a4c6f6f..2c10957 100644 --- a/tests/formatter.rs +++ b/tests/formatter.rs @@ -8,8 +8,7 @@ fn test_i_29() { let snippets = &[Group::with_title(Level::ERROR.title("oops")).element( Snippet::source("First line\r\nSecond oops line") .path("") - .annotation(AnnotationKind::Primary.span(19..23).label("oops")) - .fold(true), + .annotation(AnnotationKind::Primary.span(19..23).label("oops")), )]; let expected = str![[r#" error: oops @@ -122,8 +121,11 @@ fn test_format_title() { #[test] fn test_format_snippet_only() { let source = "This is line 1\nThis is line 2"; - let input = &[Group::with_title(Level::ERROR.title("")) - .element(Snippet::>::source(source).line_start(5402))]; + let input = &[Group::with_title(Level::ERROR.title("")).element( + Snippet::>::source(source) + .line_start(5402) + .fold(false), + )]; let expected = str![[r#" error: @@ -143,12 +145,14 @@ fn test_format_snippets_continuation() { .element( Snippet::>::source(src_0) .line_start(5402) - .path("file1.rs"), + .path("file1.rs") + .fold(false), ) .element( Snippet::>::source(src_1) .line_start(2) - .path("file2.rs"), + .path("file2.rs") + .fold(false), )]; let expected = str![[r#" error: @@ -172,11 +176,14 @@ fn test_format_snippet_annotation_standalone() { // In line 2 let range = 22..24; let input = &[Group::with_title(Level::ERROR.title("")).element( - Snippet::source(&source).line_start(5402).annotation( - AnnotationKind::Context - .span(range.clone()) - .label("Test annotation"), - ), + Snippet::source(&source) + .line_start(5402) + .fold(false) + .annotation( + AnnotationKind::Context + .span(range.clone()) + .label("Test annotation"), + ), )]; let expected = str![[r#" error: @@ -221,8 +228,11 @@ fn test_i26() { #[test] fn test_source_content() { let source = "This is an example\nof content lines"; - let input = &[Group::with_title(Level::ERROR.title("")) - .element(Snippet::>::source(source).line_start(56))]; + let input = &[Group::with_title(Level::ERROR.title("")).element( + Snippet::>::source(source) + .line_start(56) + .fold(false), + )]; let expected = str![[r#" error: | @@ -275,8 +285,11 @@ error: #[test] fn test_only_source() { - let input = &[Group::with_title(Level::ERROR.title("")) - .element(Snippet::>::source("").path("file.rs"))]; + let input = &[Group::with_title(Level::ERROR.title("")).element( + Snippet::>::source("") + .path("file.rs") + .fold(false), + )]; let expected = str![[r#" error: --> file.rs @@ -290,8 +303,11 @@ error: #[test] fn test_anon_lines() { let source = "This is an example\nof content lines\n\nabc"; - let input = &[Group::with_title(Level::ERROR.title("")) - .element(Snippet::>::source(source).line_start(56))]; + let input = &[Group::with_title(Level::ERROR.title("")).element( + Snippet::>::source(source) + .line_start(56) + .fold(false), + )]; let expected = str![[r#" error: | @@ -310,7 +326,6 @@ fn issue_130() { Snippet::source("foo\nbar\nbaz") .path("file/path") .line_start(3) - .fold(true) .annotation(AnnotationKind::Primary.span(4..11)), // bar\nbaz )]; @@ -337,7 +352,6 @@ a\" Snippet::source(source) .path("file/path") .line_start(3) - .fold(true) .annotation(AnnotationKind::Primary.span(0..10)), // 1..10 works )]; @@ -360,6 +374,7 @@ fn char_and_nl_annotate_char() { Snippet::source(source) .path("file/path") .line_start(3) + .fold(false) .annotation(AnnotationKind::Primary.span(0..2)), // a\r )]; @@ -402,6 +417,7 @@ fn char_eol_annotate_char_double_width() { let snippets = &[Group::with_title(Level::ERROR.title("")).element( Snippet::source("こん\r\nにちは\r\n世界") .path("") + .fold(false) .annotation(AnnotationKind::Primary.span(3..8)), // ん\r\n )]; @@ -428,6 +444,7 @@ fn annotate_eol() { Snippet::source(source) .path("file/path") .line_start(3) + .fold(false) .annotation(AnnotationKind::Primary.span(1..2)), // \r )]; @@ -496,6 +513,7 @@ fn annotate_eol4() { Snippet::source(source) .path("file/path") .line_start(3) + .fold(false) .annotation(AnnotationKind::Primary.span(2..2)), // \n )]; @@ -516,6 +534,7 @@ fn annotate_eol_double_width() { let snippets = &[Group::with_title(Level::ERROR.title("")).element( Snippet::source("こん\r\nにちは\r\n世界") .path("") + .fold(false) .annotation(AnnotationKind::Primary.span(7..8)), // \n )]; @@ -609,6 +628,7 @@ fn multiline_eol_start_double_width() { let snippets = &[Group::with_title(Level::ERROR.title("")).element( Snippet::source("こん\r\nにちは\r\n世界") .path("") + .fold(false) .annotation(AnnotationKind::Primary.span(7..11)), // \r\nに )]; @@ -659,6 +679,7 @@ fn multiline_eol_start_eol_end2() { Snippet::source(source) .path("file/path") .line_start(3) + .fold(false) .annotation(AnnotationKind::Primary.span(2..5)), // \nb\r )]; @@ -982,24 +1003,12 @@ fn two_suggestions_same_span() { .title("expected value, found enum `A`") .id("E0423"), ) - .element( - Snippet::source(source) - .fold(true) - .annotation(AnnotationKind::Primary.span(4..5)), - ), + .element(Snippet::source(source).annotation(AnnotationKind::Primary.span(4..5))), Group::with_title( Level::HELP.title("you might have meant to use one of the following enum variants"), ) - .element( - Snippet::source(source) - .fold(true) - .patch(Patch::new(4..5, "(A::Tuple())")), - ) - .element( - Snippet::source(source) - .fold(true) - .patch(Patch::new(4..5, "A::Unit")), - ), + .element(Snippet::source(source).patch(Patch::new(4..5, "(A::Tuple())"))) + .element(Snippet::source(source).patch(Patch::new(4..5, "A::Unit"))), ]; let expected = str![[r#" @@ -1047,7 +1056,7 @@ fn main() { .id("E0599")).element( Snippet::source(source) .line_start(1) - .fold(true) + .annotation( AnnotationKind::Context .span(18..40) @@ -1064,12 +1073,12 @@ fn main() { )) .element( Snippet::source(source) - .fold(true) + .patch(Patch::new(1..1, "use banana::Apple;\n")), ) .element( Snippet::source(source) - .fold(true) + .patch(Patch::new(1..1, "use banana::Peach;\n")), )]; let expected = str![[r#" @@ -1104,14 +1113,11 @@ fn single_line_non_overlapping_suggestions() { ) .element( Snippet::source(source) - .fold(true) .line_start(1) .annotation(AnnotationKind::Primary.span(4..5)), ), Group::with_title(Level::HELP.title("make these changes and things will work")).element( Snippet::source(source) - .fold(true) - .fold(true) .patch(Patch::new(4..5, "(A::Tuple())")) .patch(Patch::new(6..9, "bar")), ), @@ -1139,14 +1145,11 @@ fn single_line_non_overlapping_suggestions2() { let input_new = &[ Group::with_title(Level::ERROR.title("Found `ThisIsVeryLong`").id("E0423")).element( Snippet::source(source) - .fold(true) .line_start(1) .annotation(AnnotationKind::Primary.span(4..18)), ), Group::with_title(Level::HELP.title("make these changes and things will work")).element( Snippet::source(source) - .fold(true) - .fold(true) .patch(Patch::new(4..18, "(A::Tuple())")) .patch(Patch::new(19..22, "bar")), ), @@ -1187,7 +1190,6 @@ fn multiple_replacements() { .element( Snippet::source(source) .line_start(1) - .fold(true) .annotation( AnnotationKind::Primary .span(49..59) @@ -1214,7 +1216,6 @@ fn multiple_replacements() { ) .element( Snippet::source(source) - .fold(true) .patch(Patch::new(14..14, "this: &Self")) .patch(Patch::new(26..30, "this")) .patch(Patch::new(66..68, "(self)")), @@ -1269,7 +1270,6 @@ fn main() { .element( Snippet::source(source) .line_start(1) - .fold(true) .annotation( AnnotationKind::Context .span(65..70) @@ -1291,7 +1291,6 @@ fn main() { )) .element( Snippet::source(source) - .fold(true) .patch(Patch::new( 55..59, "let iter = chars.by_ref();\n while let Some(", @@ -1349,28 +1348,18 @@ fn main() {}"#; .id("E0433"), ) .element( - Snippet::source(source).line_start(1).fold(true).annotation( + Snippet::source(source).line_start(1).annotation( AnnotationKind::Primary .span(122..124) .label("use of undeclared crate or module `st`"), ), ), Group::with_title(Level::HELP.title("there is a crate or module with a similar name")) - .element( - Snippet::source(source) - .fold(true) - .patch(Patch::new(122..124, "std")), - ), - Group::with_title(Level::HELP.title("consider importing this module")).element( - Snippet::source(source) - .fold(true) - .patch(Patch::new(1..1, "use std::cell;\n")), - ), - Group::with_title(Level::HELP.title("if you import `cell`, refer to it directly")).element( - Snippet::source(source) - .fold(true) - .patch(Patch::new(122..126, "")), - ), + .element(Snippet::source(source).patch(Patch::new(122..124, "std"))), + Group::with_title(Level::HELP.title("consider importing this module")) + .element(Snippet::source(source).patch(Patch::new(1..1, "use std::cell;\n"))), + Group::with_title(Level::HELP.title("if you import `cell`, refer to it directly")) + .element(Snippet::source(source).patch(Patch::new(122..126, ""))), ]; let expected = str![[r#" error[E0433]: failed to resolve: use of undeclared crate or module `st` @@ -1424,7 +1413,6 @@ fn main() {}"#; .element( Snippet::source(source) .line_start(1) - .fold(true) .annotation( AnnotationKind::Primary .span(39..49) @@ -1440,11 +1428,7 @@ fn main() {}"#; Level::HELP .title("consider removing the `?Sized` bound to make the type parameter `Sized`"), ) - .element( - Snippet::source(source) - .fold(true) - .patch(Patch::new(52..85, "")), - ), + .element(Snippet::source(source).patch(Patch::new(52..85, ""))), ]; let expected = str![[r#" error[E0277]: the size for values of type `T` cannot be known at compilation time @@ -1489,7 +1473,7 @@ fn main() {}"#; .id("E0277")).element(Snippet::source(source) .line_start(1) .path("$DIR/removal-of-multiline-trait-bound-in-where-clause.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(39..49) @@ -1507,7 +1491,7 @@ fn main() {}"#; Snippet::source(source) .line_start(1) .path("$DIR/removal-of-multiline-trait-bound-in-where-clause.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(16..17) @@ -1521,7 +1505,7 @@ fn main() {}"#; Snippet::source(source) .line_start(1) .path("$DIR/removal-of-multiline-trait-bound-in-where-clause.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(16..17) @@ -1538,7 +1522,7 @@ fn main() {}"#; .title("consider removing the `?Sized` bound to make the type parameter `Sized`") ).element( Snippet::source(source) - .fold(true) + .patch(Patch::new(56..89, "")) .patch(Patch::new(89..89, "+ Send")) , @@ -1604,7 +1588,6 @@ zappy .element( Snippet::source(source) .line_start(7) - .fold(true) .patch(Patch::new(3..21, "")) .patch(Patch::new(22..40, "")), ), @@ -1666,7 +1649,7 @@ fn main() { .id("E0271")).element(Snippet::source(source) .line_start(4) .path("$DIR/E0271.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(208..510) @@ -1677,7 +1660,7 @@ fn main() { Snippet::source(source) .line_start(4) .path("$DIR/E0271.rs") - .fold(true) + .annotation(AnnotationKind::Primary.span(89..90)) ).element( Level::NOTE @@ -1752,7 +1735,7 @@ fn main() { .id("E0271")).element(Snippet::source(source) .line_start(4) .path("$DIR/E0271.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(208..510) @@ -1763,7 +1746,7 @@ fn main() { Snippet::source(source) .line_start(4) .path("$DIR/E0271.rs") - .fold(true) + .annotation(AnnotationKind::Primary.span(89..90)) ).element( Level::NOTE @@ -1904,7 +1887,7 @@ fn main() { Snippet::source(source) .line_start(7) .path("$DIR/long-E0308.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(719..1001) @@ -1988,7 +1971,7 @@ fn main() { Snippet::source(source) .line_start(7) .path("$DIR/unicode-output.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(430..440) @@ -2009,7 +1992,7 @@ fn main() { Snippet::source(source) .line_start(7) .path("$DIR/unicode-output.rs") - .fold(true) + .annotation(AnnotationKind::Primary.span(77..210)) .annotation(AnnotationKind::Context.span(71..76)), )]; @@ -2207,7 +2190,6 @@ fn main() { Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element( Snippet::source(source) .path("$DIR/non-whitespace-trimming-unicode.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(1207..1209) @@ -2268,7 +2250,6 @@ fn main() { .element( Snippet::source(source) .path("$DIR/non-1-width-unicode-multiline-label.rs") - .fold(true) .annotation(AnnotationKind::Context.span(970..984).label("&str")) .annotation(AnnotationKind::Context.span(987..1001).label("&str")) .annotation( @@ -2282,7 +2263,6 @@ fn main() { .element( Snippet::source(source) .path("$DIR/non-1-width-unicode-multiline-label.rs") - .fold(true) .patch(Patch::new(984..984, ".to_owned()")), ), ]; @@ -2343,14 +2323,14 @@ fn foo() { .title("couldn't read `$DIR/not-utf8.bin`: stream did not contain valid UTF-8")).element( Snippet::source(source) .path("$DIR/not-utf8.rs") - .fold(true) + .annotation(AnnotationKind::Primary.span(136..160)), ), Group::with_title(Level::NOTE.title("byte `193` is not valid utf-8")) .element( Snippet::source(bin_source) .path("$DIR/not-utf8.bin") - .fold(true) + .annotation(AnnotationKind::Primary.span(0..0)), ) .element(Level::NOTE.title("this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)")), @@ -2404,7 +2384,6 @@ fn secondary_title_no_level_text() { .element( Snippet::source(source) .path("$DIR/mismatched-types.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(105..131) @@ -2450,7 +2429,6 @@ fn secondary_title_custom_level_text() { .element( Snippet::source(source) .path("$DIR/mismatched-types.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(105..131) @@ -2524,7 +2502,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/issue-114529-illegal-break-with-value.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(483..581) @@ -2546,7 +2523,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/issue-114529-illegal-break-with-value.rs") - .fold(true) .patch(Patch::new(483..581, "break")), ), ]; diff --git a/tests/rustc_tests.rs b/tests/rustc_tests.rs index 29b8400..4b1944a 100644 --- a/tests/rustc_tests.rs +++ b/tests/rustc_tests.rs @@ -17,7 +17,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(10..13).label("test")), )]; @@ -45,7 +44,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(10..17).label("test")), )]; let expected = str![[r#" @@ -74,7 +72,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..32) @@ -115,7 +112,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..27) @@ -157,7 +153,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(17..38) @@ -199,7 +194,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..38) @@ -244,7 +238,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..38) @@ -290,7 +283,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(17..27) @@ -338,7 +330,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..27) @@ -380,7 +371,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(17..27) @@ -421,7 +411,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(18..25).label("")) .annotation( AnnotationKind::Context @@ -452,7 +441,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..27) @@ -482,7 +470,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(18..25) @@ -515,7 +502,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(14..27).label("")) .annotation( AnnotationKind::Context @@ -547,7 +533,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..18) @@ -579,7 +564,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(14..27).label("")) .annotation(AnnotationKind::Context.span(18..25).label("")), )]; @@ -605,7 +589,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(18..25).label("")) .annotation(AnnotationKind::Context.span(14..27).label("")) .annotation(AnnotationKind::Context.span(22..23).label("")), @@ -632,7 +615,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..27) @@ -669,7 +651,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(14..27) @@ -698,7 +679,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(14..27).label("")), )]; @@ -736,7 +716,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(17..27) @@ -794,7 +773,6 @@ fn foo() { Snippet::source(source) .line_start(1) .path("test.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(17..73) @@ -849,7 +827,6 @@ fn f(){||yield(((){), Snippet::source(source) .line_start(1) .path("$DIR/issue-91334.rs") - .fold(true) .annotation( AnnotationKind::Context .span(151..152) @@ -923,7 +900,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/issue-114529-illegal-break-with-value.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(483..581) @@ -942,7 +918,6 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/issue-114529-illegal-break-with-value.rs") - .fold(true) .annotation(AnnotationKind::Context.span(483..581).label("break")), ), ]; @@ -1130,7 +1105,6 @@ fn nsize() { Snippet::source(source) .line_start(1) .path("$DIR/primitive_reprs_should_have_correct_length.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(4375..4381) @@ -1141,7 +1115,6 @@ fn nsize() { Snippet::source(source) .line_start(1) .path("$DIR/primitive_reprs_should_have_correct_length.rs") - .fold(true) .annotation( AnnotationKind::Context .span(225..240) @@ -1211,7 +1184,7 @@ fn main() { .id("E027s7")).element( Snippet::source(source) .line_start(1) - .fold(true) + .path("$DIR/align-fail.rs") .annotation( AnnotationKind::Primary @@ -1281,7 +1254,6 @@ fn main() {} Snippet::source(source) .line_start(1) .path("$DIR/missing-semicolon.rs") - .fold(true) .annotation( AnnotationKind::Context .span(108..144) @@ -1372,7 +1344,7 @@ outer_macro!(FirstStruct, FirstAttrStruct); Snippet::source(aux_source) .line_start(1) .path("$DIR/auxiliary/nested-macro-rules.rs") - .fold(true) + .annotation( AnnotationKind::Context .span(41..65) @@ -1384,7 +1356,7 @@ outer_macro!(FirstStruct, FirstAttrStruct); Snippet::source(source) .line_start(1) .path("$DIR/nested-macro-rules.rs") - .fold(true) + .annotation( AnnotationKind::Context .span(510..574) @@ -1404,7 +1376,7 @@ outer_macro!(FirstStruct, FirstAttrStruct); Snippet::source(source) .line_start(1) .path("$DIR/nested-macro-rules.rs") - .fold(true) + .annotation(AnnotationKind::Primary.span(224..245)), )]; let expected = str![[r#" @@ -1503,7 +1475,6 @@ macro_rules! inline { Snippet::source(source) .line_start(1) .path("$DIR/method-on-ambiguous-numeric-type.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(916..919)), ), Group::with_title( @@ -1513,7 +1484,6 @@ macro_rules! inline { Snippet::source(aux_source) .line_start(1) .path("$DIR/auxiliary/macro-in-other-crate.rs") - .fold(true) .annotation(AnnotationKind::Context.span(69..69).label(": i32")), ), ]; @@ -1563,7 +1533,6 @@ fn main() {} Snippet::source(source) .line_start(1) .path("$DIR/issue-42234-unknown-receiver-type.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(536..539).label( "cannot infer type of the type parameter `S` declared on the method `sum`", )), @@ -1670,7 +1639,7 @@ fn main() {} Snippet::source(source) .line_start(1) .path("$DIR/empty-match.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(2911..2928) @@ -1682,7 +1651,7 @@ fn main() {} Snippet::source(source) .line_start(1) .path("$DIR/empty-match.rs") - .fold(true) + .annotation(AnnotationKind::Primary.span(818..831)) .annotation(AnnotationKind::Context.span(842..844).label("not covered")) .annotation(AnnotationKind::Context.span(854..856).label("not covered")) @@ -1701,7 +1670,7 @@ fn main() {} Snippet::source(source) .line_start(1) .path("$DIR/empty-match.rs") - .fold(true) + .annotation(AnnotationKind::Context.span(485..485).label(",\n _ => todo!()")) )]; @@ -1763,7 +1732,7 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/object-fail.rs") - .fold(true) + .annotation( AnnotationKind::Primary .span(107..114) @@ -1785,7 +1754,7 @@ fn main() { Snippet::source(source) .line_start(1) .path("$DIR/object-fail.rs") - .fold(true) + .annotation( AnnotationKind::Context .span(32..39) @@ -1827,7 +1796,6 @@ fn main() {} Group::with_title(Level::ERROR.title("mismatched types").id("E0038")).element( Snippet::source(source) .path("$DIR/long-span.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(15..5055) @@ -1861,7 +1829,6 @@ fn main() {} Group::with_title(Level::ERROR.title("mismatched types").id("E0038")).element( Snippet::source(source) .path("$DIR/long-span.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(15..5055) @@ -1896,7 +1863,6 @@ fn main() {} Group::with_title(Level::ERROR.title("mismatched types").id("E0038")).element( Snippet::source(source) .path("$DIR/long-span.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(15..5055) @@ -1931,7 +1897,6 @@ fn main() {} Group::with_title(Level::ERROR.title("mismatched types").id("E0038")).element( Snippet::source(source) .path("$DIR/long-span.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(15..5055) @@ -1983,7 +1948,7 @@ fn main() { .element( Snippet::source(source) .path("$DIR/lint_map_unit_fn.rs") - .fold(true) + .annotation(AnnotationKind::Context.span(271..278).label( "this function returns `()`, which is likely not what you wanted", )) @@ -2005,7 +1970,7 @@ fn main() { .element( Snippet::source(source) .path("$DIR/lint_map_unit_fn.rs") - .fold(true) + .patch(Patch::new(267..270, r#"for_each"#)), )]; @@ -2071,14 +2036,12 @@ fn main() { Group::with_title(Level::ERROR.title("character constant must be escaped: `\\n`")).element( Snippet::source(source) .path("$DIR/bad-char-literals.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(204..205)), ), Group::with_title(Level::HELP.title("escape the character")).element( Snippet::source(source) .path("$DIR/bad-char-literals.rs") .line_start(1) - .fold(true) .patch(Patch::new(204..205, r#"\n"#)), ), ]; @@ -2120,13 +2083,11 @@ fn main() {} Group::with_title(Level::ERROR.title("unclosed frontmatter")).element( Snippet::source(source) .path("$DIR/unclosed-1.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..221)), ), Group::with_title(Level::NOTE.title("frontmatter opening here was not closed")).element( Snippet::source(source) .path("$DIR/unclosed-1.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..4)), ), ]; @@ -2174,13 +2135,11 @@ fn foo() -> &str { Group::with_title(Level::ERROR.title("unclosed frontmatter")).element( Snippet::source(source) .path("$DIR/unclosed-2.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..377)), ), Group::with_title(Level::NOTE.title("frontmatter opening here was not closed")).element( Snippet::source(source) .path("$DIR/unclosed-2.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..4)), ), ]; @@ -2231,7 +2190,6 @@ fn foo(x: i32) -> i32 { .element( Snippet::source(source) .path("$DIR/unclosed-3.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(302..310)), ), Group::with_title( @@ -2240,7 +2198,6 @@ fn foo(x: i32) -> i32 { .element( Snippet::source(source) .path("$DIR/unclosed-3.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(302..306)), ), ]; @@ -2280,13 +2237,11 @@ fn main() {} Group::with_title(Level::ERROR.title("unclosed frontmatter")).element( Snippet::source(source) .path("$DIR/unclosed-4.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..43)), ), Group::with_title(Level::NOTE.title("frontmatter opening here was not closed")).element( Snippet::source(source) .path("$DIR/unclosed-4.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..4)), ), ]; @@ -2329,13 +2284,11 @@ fn main() {} Group::with_title(Level::ERROR.title("unclosed frontmatter")).element( Snippet::source(source) .path("$DIR/unclosed-5.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..176)), ), Group::with_title(Level::NOTE.title("frontmatter opening here was not closed")).element( Snippet::source(source) .path("$DIR/unclosed-5.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(0..4)), ), ]; @@ -2454,13 +2407,11 @@ pub enum E2 { .element( Snippet::source(source) .path("$DIR/pat-tuple-field-count-cross.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(1760..1766)), ) .element( Snippet::source(source1) .path("$DIR/auxiliary/declarations-for-tuple-field-count-errors.rs") - .fold(true) .annotation( AnnotationKind::Context .span(143..145) @@ -2476,13 +2427,11 @@ pub enum E2 { .element( Snippet::source(source) .path("$DIR/pat-tuple-field-count-cross.rs") - .fold(true) .patch(Patch::new(1760..1766, r#"E1::Z1()"#)), ), Group::with_title(Level::HELP.title("a unit variant with a similar name exists")).element( Snippet::source(source) .path("$DIR/pat-tuple-field-count-cross.rs") - .fold(true) .patch(Patch::new(1764..1766, r#"Z0"#)), ), ]; @@ -2528,7 +2477,6 @@ fn unterminated_nested_comment() { Group::with_title(Level::ERROR.title("unterminated block comment").id("E0758")).element( Snippet::source(source) .path("$DIR/unterminated-nested-comment.rs") - .fold(true) .annotation( AnnotationKind::Context .span(0..2) @@ -2584,7 +2532,6 @@ fn mismatched_types1() { Group::with_title(Level::ERROR.title("mismatched types").id("E0308")) .element( Snippet::source(file_txt_source) - .fold(true) .line_start(3) .path("$DIR/file.txt") .annotation( @@ -2596,7 +2543,6 @@ fn mismatched_types1() { .element( Snippet::source(rust_source) .path("$DIR/mismatched-types.rs") - .fold(true) .annotation( AnnotationKind::Context .span(23..28) @@ -2648,7 +2594,6 @@ fn mismatched_types2() { .element( Snippet::source(source) .path("$DIR/mismatched-types.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(105..131) @@ -2701,7 +2646,6 @@ fn main() { Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element( Snippet::source(source) .path("$DIR/short-error-format.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(80..100) @@ -2716,7 +2660,6 @@ fn main() { Group::with_title(Level::NOTE.title("function defined here")).element( Snippet::source(source) .path("$DIR/short-error-format.rs") - .fold(true) .annotation(AnnotationKind::Context.span(48..54).label("")) .annotation(AnnotationKind::Primary.span(44..47)), ), @@ -2754,7 +2697,6 @@ fn main() { .element( Snippet::source(source) .path("$DIR/short-error-format.rs") - .fold(true) .annotation( AnnotationKind::Primary .span(127..132) @@ -2789,7 +2731,6 @@ pub struct Foo; //~^ ERROR .element( Snippet::source(source_0) .path("$DIR/diagnostic-width.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(111..126)), ) .element( @@ -2798,14 +2739,12 @@ pub struct Foo; //~^ ERROR Group::with_title(Level::NOTE.title("the lint level is defined here")).element( Snippet::source(source_0) .path("$DIR/diagnostic-width.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(49..67)), ), Group::with_title(Level::HELP.title("use an automatic link instead")).element( Snippet::source(source_1) .path("$DIR/diagnostic-width.rs") .line_start(4) - .fold(true) .patch(Patch::new(40..40, "<")) .patch(Patch::new(55..55, ">")), ), @@ -2854,7 +2793,6 @@ fn main() { .element( Snippet::source(source1) .path("lint_example.rs") - .fold(true) .annotation(AnnotationKind::Primary.span(40..49)), ) .element(Level::WARNING.title("this changes meaning in Rust 2021")) @@ -2867,14 +2805,12 @@ fn main() { Snippet::source(source2) .path("lint_example.rs") .line_start(3) - .fold(true) .patch(Patch::new(10..19, "iter")), ), Group::with_title(Level::HELP.title(long_title3)).element( Snippet::source(source2) .path("lint_example.rs") .line_start(3) - .fold(true) .patch(Patch::new(0..0, "IntoIterator::into_iter(")) .patch(Patch::new(9..21, ")")), ),