support #[hdl] type aliases

This commit is contained in:
Jacob Lifshay 2024-10-30 20:47:10 -07:00
parent 20cf0abbcc
commit ee15fd2b94
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c
4 changed files with 148 additions and 3 deletions

View file

@ -31,6 +31,8 @@ pub enum E<T> {
A,
B(UInt<3>),
C(T),
D(TyAlias2),
E(TyAlias<Bool, ConstUsize<1>, { 1 + 2 }>),
}
#[hdl(outline_generated)]
@ -38,6 +40,12 @@ pub struct S2<T = ()> {
pub v: E<T>,
}
#[hdl(outline_generated)]
pub type TyAlias<T, Sz: Size, const C: usize, D = ()> = Array<S<T, Sz, D>, C>;
#[hdl(outline_generated)]
pub type TyAlias2 = TyAlias<UInt<8>, ConstUsize<24>, 5>;
// 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) => {

View file

@ -1,4 +1,4 @@
error: top-level #[hdl] can only be used on structs, enums, or functions
error: top-level #[hdl] can only be used on structs, enums, type aliases, or functions
--> tests/ui/hdl_types.rs:5:1
|
5 | #[hdl]