@@ -19,7 +19,10 @@ use noirc_errors::Location;
1919
2020use crate :: {
2121 Type , TypeBindings ,
22- ast:: { Documented , Expression , ExpressionKind , TypeImpl , UnresolvedGenerics , UnresolvedType } ,
22+ ast:: {
23+ Documented , Expression , ExpressionKind , TypeImpl , UnresolvedGenerics ,
24+ UnresolvedTraitConstraint , UnresolvedType ,
25+ } ,
2326 hir:: {
2427 comptime:: { Interpreter , InterpreterError , Value } ,
2528 def_collector:: {
@@ -58,6 +61,7 @@ struct AttributeContext {
5861struct AttributeImplTarget {
5962 object_type : UnresolvedType ,
6063 generics : UnresolvedGenerics ,
64+ where_clause : Vec < UnresolvedTraitConstraint > ,
6165 type_location : Location ,
6266}
6367
@@ -246,20 +250,7 @@ impl<'context> Elaborator<'context> {
246250 }
247251
248252 self . collect_attributes_on_functions ( functions, None , & mut attributes_to_run) ;
249- for ( ( object_type, _impl_module) , impls_in_module) in impls {
250- for ( generics, type_location, methods) in impls_in_module {
251- let impl_target = AttributeImplTarget {
252- object_type : object_type. clone ( ) ,
253- generics : generics. clone ( ) ,
254- type_location : * type_location,
255- } ;
256- self . collect_attributes_on_functions (
257- std:: slice:: from_ref ( methods) ,
258- Some ( & impl_target) ,
259- & mut attributes_to_run,
260- ) ;
261- }
262- }
253+ self . collect_attributes_on_impls ( impls, & mut attributes_to_run) ;
263254 self . collect_attributes_on_modules ( module_attributes, & mut attributes_to_run) ;
264255
265256 self . sort_attributes_by_run_order ( & mut attributes_to_run) ;
@@ -304,6 +295,29 @@ impl<'context> Elaborator<'context> {
304295 }
305296 }
306297
298+ #[ tracing:: instrument( level = "trace" , skip_all) ]
299+ fn collect_attributes_on_impls (
300+ & mut self ,
301+ impls : & ImplMap ,
302+ attributes_to_run : & mut CollectedAttributes ,
303+ ) {
304+ for ( ( object_type, _impl_module) , impls_in_module) in impls {
305+ for ( generics, where_clause, type_location, methods) in impls_in_module {
306+ let impl_target = AttributeImplTarget {
307+ object_type : object_type. clone ( ) ,
308+ generics : generics. clone ( ) ,
309+ where_clause : where_clause. clone ( ) ,
310+ type_location : * type_location,
311+ } ;
312+ self . collect_attributes_on_functions (
313+ std:: slice:: from_ref ( methods) ,
314+ Some ( & impl_target) ,
315+ attributes_to_run,
316+ ) ;
317+ }
318+ }
319+ }
320+
307321 #[ tracing:: instrument( level = "trace" , skip_all) ]
308322 fn collect_attributes_on_functions (
309323 & mut self ,
@@ -651,7 +665,7 @@ impl<'context> Elaborator<'context> {
651665 object_type : target. object_type . clone ( ) ,
652666 type_location : target. type_location ,
653667 generics : target. generics . clone ( ) ,
654- where_clause : Vec :: new ( ) ,
668+ where_clause : target . where_clause . clone ( ) ,
655669 methods : vec ! [ ( Documented :: new( function, item. doc_comments) , location) ] ,
656670 } ;
657671 let module = self . module_id ( ) ;
0 commit comments