@@ -221,13 +221,13 @@ pub fn compact(module: &mut crate::Module) {
221
221
let crate :: Comments {
222
222
module : _,
223
223
types : ref mut comment_types,
224
- struct_members : _ ,
224
+ struct_members : ref mut comment_struct_members ,
225
225
entry_points : _,
226
226
functions : _,
227
227
constants : ref mut comment_constants,
228
228
global_variables : _,
229
229
} = * * comments;
230
- log:: trace!( "adjusting comments types" ) ;
230
+ log:: trace!( "adjusting comments for types" ) ;
231
231
for comment_type_handle in comment_types. keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) {
232
232
if !module_map. types . used ( comment_type_handle) {
233
233
comment_types. swap_remove ( & comment_type_handle) ;
@@ -240,7 +240,25 @@ pub fn compact(module: &mut crate::Module) {
240
240
comment_types. insert ( handle_copy, comment) ;
241
241
}
242
242
}
243
- log:: trace!( "adjusting comments constants" ) ;
243
+ log:: trace!( "adjusting comments for struct members" ) ;
244
+ for comment_struct_member_handle in
245
+ comment_struct_members. keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( )
246
+ {
247
+ if !module_map. types . used ( comment_struct_member_handle. 0 ) {
248
+ comment_struct_members. swap_remove ( & comment_struct_member_handle) ;
249
+ continue ;
250
+ }
251
+ let mut handle_copy = comment_struct_member_handle. 0 ;
252
+ module_map. types . adjust ( & mut handle_copy) ;
253
+ if handle_copy != comment_struct_member_handle. 0 {
254
+ let comment = comment_struct_members
255
+ . swap_remove ( & comment_struct_member_handle)
256
+ . unwrap ( ) ;
257
+ comment_struct_members
258
+ . insert ( ( handle_copy, comment_struct_member_handle. 1 ) , comment) ;
259
+ }
260
+ }
261
+ log:: trace!( "adjusting comments for constants" ) ;
244
262
for comment_constant_handle in comment_constants. keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) {
245
263
if !module_map. constants . used ( comment_constant_handle) {
246
264
comment_constants. swap_remove ( & comment_constant_handle) ;
0 commit comments