forked from libre-chip/fayalite
fix #[hdl] to work with unusual identifier hygiene from macros
This commit is contained in:
parent
15a28aa7a7
commit
343805f80b
5 changed files with 202 additions and 112 deletions
|
@ -29,3 +29,69 @@ pub enum E<T> {
|
|||
pub struct S2<T = ()> {
|
||||
pub v: E<T>,
|
||||
}
|
||||
|
||||
// check that #[hdl] properly handles hygiene
|
||||
macro_rules! types_in_macros {
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident, $A:ident, $B:ident, $C:ident, $D:ident, $E:ident, $F:ident) => {
|
||||
#[hdl]
|
||||
struct $F {}
|
||||
#[hdl]
|
||||
struct $A<$B, $C: Size, const $D: usize, $E = $F> {
|
||||
$a: $B,
|
||||
$b: UIntType<$C>,
|
||||
$c: SInt<$D>,
|
||||
$d: HdlOption<$E>,
|
||||
$e: $E,
|
||||
$f: $F,
|
||||
}
|
||||
#[allow(non_camel_case_types)]
|
||||
#[hdl]
|
||||
enum $B<$C: Size, const $D: usize, $E = $F> {
|
||||
$a($A<(), $C, $D, $E>),
|
||||
$b(UIntType<$C>),
|
||||
$c(SInt<$D>),
|
||||
$d,
|
||||
$e($E),
|
||||
$f($F),
|
||||
}
|
||||
};
|
||||
// ensure every identifier has different hygiene
|
||||
() => {
|
||||
types_in_macros!(a);
|
||||
};
|
||||
($a:ident) => {
|
||||
types_in_macros!($a, b);
|
||||
};
|
||||
($a:ident, $b:ident) => {
|
||||
types_in_macros!($a, $b, c);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident) => {
|
||||
types_in_macros!($a, $b, $c, d);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, e);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, f);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, $f, A);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident, $A:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, $f, $A, B);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident, $A:ident, $B:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, $f, $A, $B, C);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident, $A:ident, $B:ident, $C:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, $f, $A, $B, $C, D);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident, $A:ident, $B:ident, $C:ident, $D:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, $f, $A, $B, $C, $D, E);
|
||||
};
|
||||
($a:ident, $b:ident, $c:ident, $d:ident, $e:ident, $f:ident, $A:ident, $B:ident, $C:ident, $D:ident, $E:ident) => {
|
||||
types_in_macros!($a, $b, $c, $d, $e, $f, $A, $B, $C, $D, $E, F);
|
||||
};
|
||||
}
|
||||
|
||||
types_in_macros!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue