}
}
-macro_rules! expand_early_lint_pass_impl_methods {
- ([$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
- $(fn $name(&mut self, context: &EarlyContext<'_>, $($param: $arg),*) {
- for obj in self.lints.iter_mut() {
- obj.$name(context, $($param),*);
- }
- })*
- )
-}
-
macro_rules! early_lint_pass_impl {
- ([], [$($methods:tt)*]) => (
+ ([], [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
impl EarlyLintPass for EarlyLintPassObjects<'_> {
- expand_early_lint_pass_impl_methods!([$($methods)*]);
+ $(fn $name(&mut self, context: &EarlyContext<'_>, $($param: $arg),*) {
+ for obj in self.lints.iter_mut() {
+ obj.$name(context, $($param),*);
+ }
+ })*
}
)
}
}
}
-macro_rules! expand_late_lint_pass_impl_methods {
- ([$hir:tt], [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
- $(fn $name(&mut self, context: &LateContext<$hir>, $($param: $arg),*) {
- for obj in self.lints.iter_mut() {
- obj.$name(context, $($param),*);
- }
- })*
- )
-}
-
macro_rules! late_lint_pass_impl {
- ([], [$hir:tt], $methods:tt) => {
+ ([], [$hir:tt], [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => {
impl<$hir> LateLintPass<$hir> for LateLintPassObjects<'_, $hir> {
- expand_late_lint_pass_impl_methods!([$hir], $methods);
+ $(fn $name(&mut self, context: &LateContext<$hir>, $($param: $arg),*) {
+ for obj in self.lints.iter_mut() {
+ obj.$name(context, $($param),*);
+ }
+ })*
}
};
}
// FIXME: eliminate the duplication with `Visitor`. But this also
// contains a few lint-specific methods with no equivalent in `Visitor`.
-macro_rules! expand_lint_pass_methods {
- ($context:ty, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
- $(#[inline(always)] fn $name(&mut self, _: $context, $(_: $arg),*) {})*
- )
-}
-
macro_rules! declare_late_lint_pass {
- ([], [$hir:tt], [$($methods:tt)*]) => (
+ ([], [$hir:tt], [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
pub trait LateLintPass<$hir>: LintPass {
- expand_lint_pass_methods!(&LateContext<$hir>, [$($methods)*]);
+ $(#[inline(always)] fn $name(&mut self, _: &LateContext<$hir>, $(_: $arg),*) {})*
}
)
}
)
}
-macro_rules! expand_early_lint_pass_methods {
- ($context:ty, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
- $(#[inline(always)] fn $name(&mut self, _: $context, $(_: $arg),*) {})*
- )
-}
-
macro_rules! declare_early_lint_pass {
- ([], [$($methods:tt)*]) => (
+ ([], [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
pub trait EarlyLintPass: LintPass {
- expand_early_lint_pass_methods!(&EarlyContext<'_>, [$($methods)*]);
+ $(#[inline(always)] fn $name(&mut self, _: &EarlyContext<'_>, $(_: $arg),*) {})*
}
)
}