Closed
Description
This works, so const generic resolution works through macros (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e93e583bc759379eae9dac80ed011361)
#![feature(const_generics)]
trait Foo {}
struct Bar<T, const N: usize>(T);
trait Qux<const N: usize> {}
macro_rules! bar {
($t:ty) => {
impl<T, const N: usize> Foo for $t
{}
}
}
bar!(Bar<T, {N}>);
This also works, so const generics work in a where guard (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=cde12aadff1355221b94beef0782da9c)
#![feature(const_generics)]
trait Foo {}
struct Bar<T, const N: usize>(T);
trait Qux<const N: usize> {}
impl<T, const N: usize> Foo for Bar<T, {N}>
where (): Qux<{N}>
{}
But if I combine those together, all of a sudden it has name resolution problems (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c11ade7c9cc0f31a0fc538816bbe0719)
#![feature(const_generics)]
trait Foo {}
struct Bar<T, const N: usize>(T);
trait Qux<const N: usize> {}
macro_rules! bar {
($t:ty) => {
impl<T, const N: usize> Foo for $t
where (): Qux<{N}>
{}
}
}
bar!(Bar<T, {N}>);
error[E0425]: cannot find value `N` in this scope
--> src/lib.rs:8:28
|
8 | where (): Qux<{N}>
| ^ not found in this scope
...
12 | bar!(Bar<T, {N}>);
| ------------------ in this macro invocation
So something seems weird, but I have no idea what it could be