@@ -19,7 +19,7 @@ use crate::hir_def::{
1919 function:: { FuncMeta , HirFunction } ,
2020 stmt:: HirStatement ,
2121} ;
22- use crate :: token:: Attributes ;
22+ use crate :: token:: { Attributes , SecondaryAttribute } ;
2323use crate :: {
2424 ContractFunctionType , FunctionDefinition , Generics , Shared , TypeAliasType , TypeBinding ,
2525 TypeBindings , TypeVariable , TypeVariableId , TypeVariableKind , Visibility ,
@@ -32,6 +32,8 @@ pub struct TraitImplKey {
3232 // pub generics: Generics - TODO
3333}
3434
35+ type StructAttributes = Vec < SecondaryAttribute > ;
36+
3537/// The node interner is the central storage location of all nodes in Noir's Hir (the
3638/// various node types can be found in hir_def). The interner is also used to collect
3739/// extra information about the Hir, such as the type of each node, information about
@@ -73,6 +75,7 @@ pub struct NodeInterner {
7375 // methods from impls to the type.
7476 structs : HashMap < StructId , Shared < StructType > > ,
7577
78+ struct_attributes : HashMap < StructId , StructAttributes > ,
7679 // Type Aliases map.
7780 //
7881 // Map type aliases to the actual type.
@@ -365,6 +368,7 @@ impl Default for NodeInterner {
365368 definitions : vec ! [ ] ,
366369 id_to_type : HashMap :: new ( ) ,
367370 structs : HashMap :: new ( ) ,
371+ struct_attributes : HashMap :: new ( ) ,
368372 type_aliases : Vec :: new ( ) ,
369373 traits : HashMap :: new ( ) ,
370374 trait_implementations : HashMap :: new ( ) ,
@@ -456,6 +460,7 @@ impl NodeInterner {
456460
457461 let new_struct = StructType :: new ( struct_id, name, typ. struct_def . span , no_fields, generics) ;
458462 self . structs . insert ( struct_id, Shared :: new ( new_struct) ) ;
463+ self . struct_attributes . insert ( struct_id, typ. struct_def . attributes . clone ( ) ) ;
459464 struct_id
460465 }
461466
@@ -678,6 +683,10 @@ impl NodeInterner {
678683 & self . function_modifiers [ func_id] . attributes
679684 }
680685
686+ pub fn struct_attributes ( & self , struct_id : & StructId ) -> & StructAttributes {
687+ & self . struct_attributes [ struct_id]
688+ }
689+
681690 /// Returns the interned statement corresponding to `stmt_id`
682691 pub fn statement ( & self , stmt_id : & StmtId ) -> HirStatement {
683692 let def =
0 commit comments