2020-11-18 06:55:35 -06:00
|
|
|
mod m {
|
|
|
|
pub const P: usize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Q: usize = 0;
|
|
|
|
|
2020-11-10 02:48:04 -06:00
|
|
|
fn test<const N: usize>() {
|
|
|
|
struct Foo<const M: usize>;
|
|
|
|
macro_rules! foo {
|
|
|
|
($x:expr) => {
|
2021-08-27 11:04:57 -05:00
|
|
|
[u8; $x]
|
2020-11-10 02:48:04 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
macro_rules! bar {
|
|
|
|
($x:expr) => {
|
2021-08-27 11:04:57 -05:00
|
|
|
[u8; { $x }]
|
2020-11-10 02:48:04 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
macro_rules! baz {
|
|
|
|
( $x:expr) => {
|
2021-08-27 11:04:57 -05:00
|
|
|
Foo<$x>
|
2020-11-10 02:48:04 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
macro_rules! biz {
|
|
|
|
($x:expr) => {
|
2021-08-27 11:04:57 -05:00
|
|
|
Foo<{ $x }>
|
2020-11-10 02:48:04 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
let _: foo!(N);
|
|
|
|
let _: foo!({ N });
|
2021-08-27 11:04:57 -05:00
|
|
|
let _: foo!({{ N }}); //~ ERROR generic parameters may not
|
2020-11-18 06:55:35 -06:00
|
|
|
let _: foo!(Q);
|
|
|
|
let _: foo!(m::P);
|
2020-11-10 02:48:04 -06:00
|
|
|
let _: bar!(N);
|
2021-08-27 11:04:57 -05:00
|
|
|
let _: bar!({ N }); //~ ERROR generic parameters may not
|
2020-11-18 06:55:35 -06:00
|
|
|
let _: bar!(Q);
|
|
|
|
let _: bar!(m::P);
|
2020-11-18 06:49:39 -06:00
|
|
|
let _: baz!(N);
|
2020-11-10 02:48:04 -06:00
|
|
|
let _: baz!({ N });
|
2021-08-27 11:04:57 -05:00
|
|
|
let _: baz!({{ N }}); //~ ERROR generic parameters may not
|
2020-11-18 06:55:35 -06:00
|
|
|
let _: baz!(Q);
|
|
|
|
let _: baz!({ m::P });
|
|
|
|
let _: baz!(m::P); //~ ERROR expressions must be enclosed in braces
|
2020-11-10 02:48:04 -06:00
|
|
|
let _: biz!(N);
|
2021-08-27 11:04:57 -05:00
|
|
|
let _: biz!({ N }); //~ ERROR generic parameters may not
|
2020-11-18 06:55:35 -06:00
|
|
|
let _: biz!(Q);
|
|
|
|
let _: biz!(m::P);
|
2020-11-17 03:18:27 -06:00
|
|
|
let _: foo!(3);
|
|
|
|
let _: foo!({ 3 });
|
|
|
|
let _: foo!({{ 3 }});
|
|
|
|
let _: bar!(3);
|
|
|
|
let _: bar!({ 3 });
|
|
|
|
let _: baz!(3);
|
|
|
|
let _: baz!({ 3 });
|
|
|
|
let _: baz!({{ 3 }});
|
|
|
|
let _: biz!(3);
|
|
|
|
let _: biz!({ 3 });
|
|
|
|
let _: foo!(10 + 7);
|
|
|
|
let _: foo!({ 10 + 7 });
|
|
|
|
let _: foo!({{ 10 + 7 }});
|
|
|
|
let _: bar!(10 + 7);
|
|
|
|
let _: bar!({ 10 + 7 });
|
|
|
|
let _: baz!(10 + 7); //~ ERROR expressions must be enclosed in braces
|
|
|
|
let _: baz!({ 10 + 7 });
|
|
|
|
let _: baz!({{ 10 + 7 }});
|
|
|
|
let _: biz!(10 + 7);
|
|
|
|
let _: biz!({ 10 + 7 });
|
2020-11-10 02:48:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test::<3>();
|
|
|
|
}
|