@@ -103,18 +103,18 @@ type GroupType<S> = LazyLock<GroupTypeInner<S>>;
103103
104104pub ( super ) struct GroupTypeInner < S : Stage > {
105105 pub ( super ) accepters : BTreeMap < & ' static [ Symbol ] , Vec < GroupTypeInnerAccept < S > > > ,
106- pub ( super ) finalizers : Vec < FinalizeFn < S > > ,
107106}
108107
109108pub ( super ) struct GroupTypeInnerAccept < S : Stage > {
110109 pub ( super ) template : AttributeTemplate ,
111110 pub ( super ) accept_fn : AcceptFn < S > ,
112111 pub ( super ) allowed_targets : AllowedTargets ,
112+ pub ( super ) finalizer : FinalizeFn < S > ,
113113}
114114
115- type AcceptFn < S > =
115+ pub ( crate ) type AcceptFn < S > =
116116 Box < dyn for <' sess , ' a > Fn ( & mut AcceptContext < ' _ , ' sess , S > , & ArgParser ) + Send + Sync > ;
117- type FinalizeFn < S > =
117+ pub ( crate ) type FinalizeFn < S > =
118118 Box < dyn Send + Sync + Fn ( & mut FinalizeContext < ' _ , ' _ , S > ) -> Option < AttributeKind > > ;
119119
120120macro_rules! attribute_parsers {
@@ -142,34 +142,32 @@ macro_rules! attribute_parsers {
142142 @[ $stage: ty] pub ( crate ) static $name: ident = [ $( $names: ty) ,* $( , ) ?] ;
143143 ) => {
144144 pub ( crate ) static $name: GroupType <$stage> = LazyLock :: new( || {
145- let mut accepts = BTreeMap :: <_, Vec <GroupTypeInnerAccept <$stage>>>:: new( ) ;
146- let mut finalizes = Vec :: <FinalizeFn <$stage>>:: new( ) ;
145+ let mut accepters = BTreeMap :: <_, Vec <GroupTypeInnerAccept <$stage>>>:: new( ) ;
147146 $(
148147 {
149148 thread_local! {
150149 static STATE_OBJECT : RefCell <$names> = RefCell :: new( <$names>:: default ( ) ) ;
151150 } ;
152151
153152 for ( path, template, accept_fn) in <$names>:: ATTRIBUTES {
154- accepts . entry( * path) . or_default( ) . push( GroupTypeInnerAccept {
153+ accepters . entry( * path) . or_default( ) . push( GroupTypeInnerAccept {
155154 template: * template,
156155 accept_fn: Box :: new( |cx, args| {
157156 STATE_OBJECT . with_borrow_mut( |s| {
158157 accept_fn( s, cx, args)
159158 } )
160159 } ) ,
161160 allowed_targets: <$names as crate :: attributes:: AttributeParser <$stage>>:: ALLOWED_TARGETS ,
161+ finalizer: Box :: new( |cx| {
162+ let state = STATE_OBJECT . take( ) ;
163+ state. finalize( cx)
164+ } ) ,
162165 } ) ;
163166 }
164-
165- finalizes. push( Box :: new( |cx| {
166- let state = STATE_OBJECT . take( ) ;
167- state. finalize( cx)
168- } ) ) ;
169167 }
170168 ) *
171169
172- GroupTypeInner { accepters: accepts , finalizers : finalizes }
170+ GroupTypeInner { accepters }
173171 } ) ;
174172 } ;
175173}
0 commit comments