This is a simplified example from some library code. For some reason, the function m
is callable in that scope but the closure n
isn't:
pub trait TestTrait {
fn testFunc();
}
macro_rules! custom {
($body:expr) => {
fn testFunc() {
fn m() {}
let n = || {};
$body
}
};
}
macro_rules! int_custom {
() => {
impl TestTrait for i32 {
custom!({
m();
n();
});
}
};
}
int_custom!();
fn main() {
println!("Test");
}
error[E0425]: cannot find function `n` in this scope
--> src/main.rs:20:17
|
20 | n();
| ^ not found in this scope
...
26 | int_custom!();
| -------------- in this macro invocation
Why is this the case?