Skip to content

Commit b3a3ab1

Browse files
committed
Add mut_only_visit!
1 parent 7f27f35 commit b3a3ab1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ macro_rules! make_ast_visitor {
107107
};
108108
}
109109

110+
#[allow(unused)]
111+
macro_rules! mut_only_visit {
112+
($name: ident) => {
113+
macro_rules! $name {
114+
($vis: expr, $arg: expr) => {
115+
macro_if!{ $($mut)? {
116+
$name($vis, $arg)
117+
} else {
118+
// assign to _ to prevent unused_variable warnings
119+
{let _ = (&$vis, &$arg);}
120+
}}
121+
};
122+
}
123+
};
124+
}
125+
110126
#[allow(unused)]
111127
macro_rules! try_v {
112128
($visit: expr) => {

0 commit comments

Comments
 (0)