Closed
Description
nightly 2019-05-10 d595b113584f8f446957
#![feature(const_generics)]
macro_rules! compile {
($t:ty; $e:expr) => {{
fn compiletime<const N: $t>() -> $t {
N
}
compiletime::<{ $e }>()
}};
}
const fn square(x: usize) -> usize {
x * x
}
fn main() {
let mut x = compile! { usize;
square(4) + square(5)
};
x += 1;
println!("{}", x);
}
Produces the error:
error[E0425]: cannot find value `N` in this scope
--> src/main.rs:6:13
|
6 | N
| ^ not found in this scope
...
17 | let mut x = compile! { usize;
| _________________-
18 | | square(4) + square(5)
19 | | };
| |_____- in this macro invocation
Without the macro:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3bc031a4b607a3128a5ce1f53564c181
42