Skip to content

Commit

Permalink
adjust types for struct members
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Jan 10, 2025
1 parent 39bf048 commit fa550b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
24 changes: 21 additions & 3 deletions naga/src/compact/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ pub fn compact(module: &mut crate::Module) {
let crate::Comments {
module: _,
types: ref mut comment_types,
struct_members: _,
struct_members: ref mut comment_struct_members,
entry_points: _,
functions: _,
constants: ref mut comment_constants,
global_variables: _,
} = **comments;
log::trace!("adjusting comments types");
log::trace!("adjusting comments for types");
for comment_type_handle in comment_types.keys().cloned().collect::<Vec<_>>() {
if !module_map.types.used(comment_type_handle) {
comment_types.swap_remove(&comment_type_handle);
Expand All @@ -240,7 +240,25 @@ pub fn compact(module: &mut crate::Module) {
comment_types.insert(handle_copy, comment);
}
}
log::trace!("adjusting comments constants");
log::trace!("adjusting comments for struct members");
for comment_struct_member_handle in
comment_struct_members.keys().cloned().collect::<Vec<_>>()
{
if !module_map.types.used(comment_struct_member_handle.0) {
comment_struct_members.swap_remove(&comment_struct_member_handle);
continue;
}
let mut handle_copy = comment_struct_member_handle.0;
module_map.types.adjust(&mut handle_copy);
if handle_copy != comment_struct_member_handle.0 {
let comment = comment_struct_members
.swap_remove(&comment_struct_member_handle)
.unwrap();
comment_struct_members
.insert((handle_copy, comment_struct_member_handle.1), comment);
}
}
log::trace!("adjusting comments for constants");
for comment_constant_handle in comment_constants.keys().cloned().collect::<Vec<_>>() {
if !module_map.constants.used(comment_constant_handle) {
comment_constants.swap_remove(&comment_constant_handle);
Expand Down
1 change: 1 addition & 0 deletions naga/src/valid/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ impl super::Validator {
}
_ => {
// TODO: internal error ? We should never get here.
// If entering there, it's probably that we forgot to adjust a handle in the compact phase.
return Err(ValidationError::Type {
handle: comment_struct_member_doc.0 .0,
name: struct_type
Expand Down

0 comments on commit fa550b5

Please sign in to comment.