-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
DutchGhost
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.