Roll out the new children functions to all compare functions using the new compare_properties macro.

We will roll it out to the rest of them when we move them over to the new compare_properties macro.
This commit is contained in:
Tom Alexander 2023-10-09 13:08:45 -04:00
parent c49556bd5d
commit e39562c85d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 68 additions and 35 deletions

View File

@ -2584,20 +2584,24 @@ fn compare_bold<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b Bold<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? {
this_status = new_status;
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2614,20 +2618,24 @@ fn compare_italic<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b Italic<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? {
this_status = new_status;
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2644,20 +2652,24 @@ fn compare_underline<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b Underline<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? {
this_status = new_status;
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2677,6 +2689,8 @@ fn compare_verbatim<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -2709,6 +2723,8 @@ fn compare_code<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -2738,20 +2754,24 @@ fn compare_strike_through<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b StrikeThrough<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? {
this_status = new_status;
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2768,11 +2788,19 @@ fn compare_regular_link<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b RegularLink<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -2820,10 +2848,6 @@ fn compare_regular_link<'b, 's>(
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2840,11 +2864,19 @@ fn compare_radio_link<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b RadioLink<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -2883,10 +2915,6 @@ fn compare_radio_link<'b, 's>(
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2903,7 +2931,6 @@ fn compare_radio_target<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b RadioTarget<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
@ -2930,10 +2957,6 @@ fn compare_radio_target<'b, 's>(
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
@ -2953,6 +2976,8 @@ fn compare_plain_link<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -3019,6 +3044,8 @@ fn compare_angle_link<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -3085,6 +3112,8 @@ fn compare_org_macro<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -3131,6 +3160,8 @@ fn compare_entity<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
@ -3199,6 +3230,8 @@ fn compare_latex_fragment<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,