From eaa38ce772aa6721e29c86e6b62db38ac532942a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 29 Aug 2023 21:05:51 -0400 Subject: [PATCH] Include an error message for failed bounds checking. --- src/compare/diff.rs | 671 ++++++++++++++++++++++++++++++-------------- 1 file changed, 464 insertions(+), 207 deletions(-) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 7116f30..a32f208 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -347,15 +347,19 @@ fn compare_section<'s>( let children = emacs.as_list()?; let mut this_status = DiffStatus::Good; let mut child_status = Vec::new(); + let mut message = None; let emacs_name = "section"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } - + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_element(source, emacs_child, rust_child)?); } @@ -363,7 +367,7 @@ fn compare_section<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -384,9 +388,13 @@ fn compare_heading<'s>( this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; // Compare tags let emacs_tags = get_tags_from_heading(emacs)?; @@ -502,14 +510,19 @@ fn compare_paragraph<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "paragraph"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_object(source, emacs_child, rust_child)?); @@ -518,7 +531,7 @@ fn compare_paragraph<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -533,14 +546,19 @@ fn compare_plain_list<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "plain-list"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_plain_list_item(source, emacs_child, rust_child)?); @@ -549,7 +567,7 @@ fn compare_plain_list<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -570,9 +588,13 @@ fn compare_plain_list_item<'s>( this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; // Compare tag let tag = get_property(emacs, ":tag")?; @@ -632,6 +654,7 @@ fn compare_greater_block<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = match rust.name.to_lowercase().as_str() { "center" => "center-block", "quote" => "quote-block", @@ -641,9 +664,13 @@ fn compare_greater_block<'s>( this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_element(source, emacs_child, rust_child)?); @@ -652,7 +679,7 @@ fn compare_greater_block<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -667,13 +694,18 @@ fn compare_dynamic_block<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; if assert_name(emacs, "dynamic-block").is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_element(source, emacs_child, rust_child)?); @@ -682,7 +714,7 @@ fn compare_dynamic_block<'s>( Ok(DiffResult { status: this_status, name: "dynamic-block".to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -697,14 +729,19 @@ fn compare_footnote_definition<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "footnote-definition"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_element(source, emacs_child, rust_child)?); @@ -713,7 +750,7 @@ fn compare_footnote_definition<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -727,19 +764,24 @@ fn compare_comment<'s>( ) -> Result, Box> { let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "comment"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -754,14 +796,19 @@ fn compare_drawer<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "drawer"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_element(source, emacs_child, rust_child)?); @@ -770,7 +817,7 @@ fn compare_drawer<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -785,14 +832,19 @@ fn compare_property_drawer<'s>( let children = emacs.as_list()?; let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "property-drawer"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) { // TODO: What are node properties and are they the only legal child of property drawers? @@ -802,7 +854,7 @@ fn compare_property_drawer<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -817,14 +869,19 @@ fn compare_table<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "table"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_table_row(source, emacs_child, rust_child)?); @@ -833,7 +890,7 @@ fn compare_table<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -848,14 +905,19 @@ fn compare_table_row<'s>( let children = emacs.as_list()?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "table-row"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_table_cell(source, emacs_child, rust_child)?); @@ -864,7 +926,7 @@ fn compare_table_row<'s>( Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -879,21 +941,26 @@ fn compare_table_cell<'s>( let children = emacs.as_list()?; let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "table-cell"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {} Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -908,21 +975,26 @@ fn compare_verse_block<'s>( let children = emacs.as_list()?; let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "verse-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {} Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -935,19 +1007,24 @@ fn compare_comment_block<'s>( rust: &'s CommentBlock<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "comment-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -960,19 +1037,24 @@ fn compare_example_block<'s>( rust: &'s ExampleBlock<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "example-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -985,19 +1067,24 @@ fn compare_export_block<'s>( rust: &'s ExportBlock<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "export-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1010,19 +1097,24 @@ fn compare_src_block<'s>( rust: &'s SrcBlock<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "src-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1035,19 +1127,24 @@ fn compare_clock<'s>( rust: &'s Clock<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "clock"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1060,19 +1157,24 @@ fn compare_diary_sexp<'s>( rust: &'s DiarySexp<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "diary-sexp"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1085,19 +1187,24 @@ fn compare_planning<'s>( rust: &'s Planning<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "planning"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1111,19 +1218,24 @@ fn compare_fixed_width_area<'s>( ) -> Result, Box> { let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "fixed-width"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -1137,19 +1249,24 @@ fn compare_horizontal_rule<'s>( ) -> Result, Box> { let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "horizontal-rule"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -1163,19 +1280,24 @@ fn compare_keyword<'s>( ) -> Result, Box> { let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "keyword"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -1189,19 +1311,24 @@ fn compare_latex_environment<'s>( ) -> Result, Box> { let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "latex-environment"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: child_status, rust_source: rust.get_source(), emacs_token: emacs, @@ -1263,19 +1390,24 @@ fn compare_bold<'s>( rust: &'s Bold<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "bold"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1288,19 +1420,24 @@ fn compare_italic<'s>( rust: &'s Italic<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "italic"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1313,19 +1450,24 @@ fn compare_underline<'s>( rust: &'s Underline<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "underline"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1338,19 +1480,24 @@ fn compare_verbatim<'s>( rust: &'s Verbatim<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "verbatim"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1363,19 +1510,24 @@ fn compare_code<'s>( rust: &'s Code<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "code"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1388,19 +1540,24 @@ fn compare_strike_through<'s>( rust: &'s StrikeThrough<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "strike-through"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1413,19 +1570,24 @@ fn compare_regular_link<'s>( rust: &'s RegularLink<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "link"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1438,19 +1600,24 @@ fn compare_radio_link<'s>( rust: &'s RadioLink<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "link"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1463,19 +1630,24 @@ fn compare_radio_target<'s>( rust: &'s RadioTarget<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "radio-target"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1488,19 +1660,24 @@ fn compare_plain_link<'s>( rust: &'s PlainLink<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "link"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1513,19 +1690,24 @@ fn compare_angle_link<'s>( rust: &'s AngleLink<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "link"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1538,19 +1720,24 @@ fn compare_org_macro<'s>( rust: &'s OrgMacro<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "macro"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1563,19 +1750,24 @@ fn compare_entity<'s>( rust: &'s Entity<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "entity"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1588,19 +1780,24 @@ fn compare_latex_fragment<'s>( rust: &'s LatexFragment<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "latex-fragment"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1613,19 +1810,24 @@ fn compare_export_snippet<'s>( rust: &'s ExportSnippet<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "export-snippet"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1638,19 +1840,24 @@ fn compare_footnote_reference<'s>( rust: &'s FootnoteReference<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "footnote-reference"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1663,19 +1870,24 @@ fn compare_citation<'s>( rust: &'s Citation<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "citation"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1688,19 +1900,24 @@ fn compare_citation_reference<'s>( rust: &'s CitationReference<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "citation-reference"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1713,19 +1930,24 @@ fn compare_inline_babel_call<'s>( rust: &'s InlineBabelCall<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "inline-babel-call"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1738,19 +1960,24 @@ fn compare_inline_source_block<'s>( rust: &'s InlineSourceBlock<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "inline-src-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1763,19 +1990,24 @@ fn compare_line_break<'s>( rust: &'s LineBreak<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "line-break"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1788,19 +2020,24 @@ fn compare_target<'s>( rust: &'s Target<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "target"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1813,19 +2050,24 @@ fn compare_statistics_cookie<'s>( rust: &'s StatisticsCookie<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "statistics-cookie"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1838,19 +2080,24 @@ fn compare_subscript<'s>( rust: &'s Subscript<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "subscript"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1863,19 +2110,24 @@ fn compare_superscript<'s>( rust: &'s Superscript<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "superscript"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs, @@ -1888,19 +2140,24 @@ fn compare_timestamp<'s>( rust: &'s Timestamp<'s>, ) -> Result, Box> { let mut this_status = DiffStatus::Good; + let mut message = None; let emacs_name = "timestamp"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } - if assert_bounds(source, emacs, rust).is_err() { - this_status = DiffStatus::Bad; - } + match assert_bounds(source, emacs, rust) { + Err(err) => { + this_status = DiffStatus::Bad; + message = Some(err.to_string()) + } + Ok(_) => {} + }; Ok(DiffResult { status: this_status, name: emacs_name.to_owned(), - message: None, + message, children: Vec::new(), rust_source: rust.get_source(), emacs_token: emacs,