diff --git a/crates/wasmparser/src/readers/core/operators.rs b/crates/wasmparser/src/readers/core/operators.rs index 94a4422030..d1312c259f 100644 --- a/crates/wasmparser/src/readers/core/operators.rs +++ b/crates/wasmparser/src/readers/core/operators.rs @@ -331,16 +331,24 @@ macro_rules! define_visit_operator_delegate { ($(@$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*) => { $( fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { - V::$visit(*self, $($($arg),*)?) + V::$visit(&mut *self, $($($arg),*)?) } )* } } -impl<'a, 'b, V: VisitOperator<'a>> VisitOperator<'a> for &'b mut V { +impl<'a, 'b, V: VisitOperator<'a> + ?Sized> VisitOperator<'a> for &'b mut V { type Output = V::Output; fn visit_operator(&mut self, op: &Operator<'a>) -> Self::Output { V::visit_operator(*self, op) } for_each_operator!(define_visit_operator_delegate); } + +impl<'a, V: VisitOperator<'a> + ?Sized> VisitOperator<'a> for Box { + type Output = V::Output; + fn visit_operator(&mut self, op: &Operator<'a>) -> Self::Output { + V::visit_operator(&mut *self, op) + } + for_each_operator!(define_visit_operator_delegate); +}