Wrap the parameter sets in parenthesis.
This commit is contained in:
parent
c7dbe596b3
commit
368c6a457e
@ -15,14 +15,23 @@ pub(crate) enum EmacsField<'s> {
|
||||
///
|
||||
/// This is for when you want to acknowledge that a field exists in the emacs token, but you do not have any validation for it when using the compare_properties!() macro. Ideally, this should be kept to a minimum since this represents untested values.
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn compare_noop<'b, 's, 'x>(
|
||||
pub(crate) fn impl_compare_noop<'b, 's, 'x, R, RG>(
|
||||
_emacs: &'b Token<'s>,
|
||||
_rust_node: R,
|
||||
_emacs_field: &'x str,
|
||||
_rust_value: (),
|
||||
_rust_value_getter: RG,
|
||||
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Do no comparison.
|
||||
///
|
||||
/// This is for when you want to acknowledge that a field exists in the emacs token, but you do not have any validation for it when using the compare_properties!() macro. Ideally, this should be kept to a minimum since this represents untested values.
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn compare_identity() -> () {
|
||||
()
|
||||
}
|
||||
|
||||
pub(crate) fn compare_property_quoted_string<'b, 's, 'x, R, RG: Fn(R) -> Option<&'s str>>(
|
||||
emacs: &'b Token<'s>,
|
||||
rust_node: R,
|
||||
|
@ -3,8 +3,9 @@ use std::borrow::Cow;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::compare_field::compare_identity;
|
||||
use super::compare_field::compare_property_quoted_string;
|
||||
use super::compare_field::compare_property_quoted_string_required_value;
|
||||
use super::compare_field::impl_compare_noop;
|
||||
use super::elisp_fact::ElispFact;
|
||||
use super::elisp_fact::GetElispFact;
|
||||
use super::sexp::unquote;
|
||||
@ -2661,9 +2662,21 @@ fn compare_verbatim<'b, 's>(
|
||||
if let Some((new_status, new_message)) = compare_properties!(
|
||||
emacs,
|
||||
rust,
|
||||
EmacsField::Required(":value"),
|
||||
|r| Some(r.contents),
|
||||
compare_property_quoted_string
|
||||
(
|
||||
EmacsField::Required(":value"),
|
||||
|r| Some(r.contents),
|
||||
compare_property_quoted_string
|
||||
),
|
||||
(
|
||||
EmacsField::Required(":value"),
|
||||
|r| Some(r.contents),
|
||||
compare_property_quoted_string
|
||||
),
|
||||
(
|
||||
EmacsField::Required(":foo"),
|
||||
compare_identity,
|
||||
impl_compare_noop
|
||||
)
|
||||
)? {
|
||||
this_status = new_status;
|
||||
message = new_message;
|
||||
@ -2691,9 +2704,11 @@ fn compare_code<'b, 's>(
|
||||
if let Some((new_status, new_message)) = compare_properties!(
|
||||
emacs,
|
||||
rust,
|
||||
EmacsField::Required(":value"),
|
||||
|r| Some(r.contents),
|
||||
compare_property_quoted_string
|
||||
(
|
||||
EmacsField::Required(":value"),
|
||||
|r| Some(r.contents),
|
||||
compare_property_quoted_string
|
||||
)
|
||||
)? {
|
||||
this_status = new_status;
|
||||
message = new_message;
|
||||
|
@ -1,6 +1,18 @@
|
||||
macro_rules! compare_noop {
|
||||
($($field:expr),+) => {
|
||||
$(
|
||||
EmacsField::Required(":foo"),
|
||||
compare_identity,
|
||||
impl_compare_noop
|
||||
),+
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use compare_noop;
|
||||
|
||||
/// Create iterators for ast nodes where it only has to iterate over children
|
||||
macro_rules! compare_properties {
|
||||
($emacs:expr, $rust:expr, $($emacs_field:expr, $rust_value_getter:expr, $compare_fn: ident),+) => {
|
||||
($emacs:expr, $rust:expr, $(($emacs_field:expr, $rust_value_getter:expr, $compare_fn: expr)),+) => {
|
||||
{
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message: Option<String> = None;
|
||||
@ -36,7 +48,7 @@ macro_rules! compare_properties {
|
||||
},
|
||||
EmacsField::Optional(_name) => {},
|
||||
}
|
||||
),+
|
||||
)+
|
||||
|
||||
if !emacs_keys.is_empty() {
|
||||
let unexpected_keys: Vec<&str> = emacs_keys.into_iter().collect();
|
||||
@ -66,7 +78,7 @@ macro_rules! compare_properties {
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
),+
|
||||
)+
|
||||
|
||||
match this_status {
|
||||
DiffStatus::Good => {
|
||||
|
Loading…
Reference in New Issue
Block a user