Adjust macros to new version

This commit is contained in:
Laurenz 2021-08-14 23:53:57 +02:00
parent 6ae6d86b9c
commit 7e6e7e928c
3 changed files with 13 additions and 13 deletions

View File

@ -7,11 +7,11 @@ use crate::syntax::{Span, Spanned};
/// Early-return with a vec-boxed [`Error`].
macro_rules! bail {
($span:expr, $message:expr $(,)?) => {
return Err($crate::diag::Error::boxed($span, $message,));
return Err($crate::diag::Error::boxed($span, $message,))
};
($span:expr, $fmt:expr, $($arg:expr),+ $(,)?) => {
bail!($span, format!($fmt, $($arg),+));
bail!($span, format!($fmt, $($arg),+))
};
}

View File

@ -7,7 +7,7 @@ use Value::*;
/// Bail with a type mismatch error.
macro_rules! mismatch {
($fmt:expr, $($value:expr),* $(,)?) => {
return Err(format!($fmt, $($value.type_name()),*));
return Err(format!($fmt, $($value.type_name()),*))
};
}

View File

@ -11,10 +11,9 @@ macro_rules! impl_visitors {
}
impl_visitor! {
/// Walk syntax trees immutably.
Visit,
/// Immutable visitor functions.
immutable,
immutably,
[$(($name($($tts)*) $body))*]
}
@ -24,10 +23,9 @@ macro_rules! impl_visitors {
}
impl_visitor! {
/// Walk syntax trees mutably.
VisitMut,
/// Mutable visitor functions.
mutable,
mutably,
[$(($name($($tts)*) $body mut))*] mut
}
};
@ -36,8 +34,9 @@ macro_rules! impl_visitors {
/// Implement an immutable or mutable visitor.
macro_rules! impl_visitor {
(
#[doc = $visit_doc:expr] $visit:ident,
#[doc = $module_doc:expr] $module:ident,
$visit:ident,
$mutability:ident,
$adjective:ident,
[$((
$name:ident($v:ident, $node:ident: $ty:ty)
$body:block
@ -45,7 +44,7 @@ macro_rules! impl_visitor {
))*]
$($mut:tt)?
) => {
#[doc = $visit_doc]
#[doc = concat!("Visit syntax trees ", stringify!($adjective), ".")]
pub trait $visit<'ast> {
/// Visit a definition of a binding.
///
@ -60,14 +59,15 @@ macro_rules! impl_visitor {
fn visit_exit(&mut self) {}
$(fn $name(&mut self, $node: &'ast $($fmut)? $ty) {
$module::$name(self, $node);
$mutability::$name(self, $node);
})*
}
#[doc = $module_doc]
pub mod $module {
#[doc = concat!("Visitor functions that are ", stringify!($mutability), ".")]
pub mod $mutability {
use super::*;
$(
#[doc = concat!("Visit a node of type [`", stringify!($ty), "`].")]
pub fn $name<'ast, V>($v: &mut V, $node: &'ast $($fmut)? $ty)
where
V: $visit<'ast> + ?Sized