Skip to content

Commit

Permalink
Properly propagate deps for non-POD structs
Browse files Browse the repository at this point in the history
Bug #1170 is a bug where a type wasn't deemed movable, and because it
appeared in a vector, that meant misgeneration of code.

Movability calculations are done based on the presence of move
constructors for each field type. This analysis is done in a
depth-first fashion, to ensure that fields of fields are calculated
first. However, this depth-first analysis wasn't working correctly
because we weren't considering all the links in that tree.
Specifically, a type A was considered to depend on its field type
B only for POD structs in the past. It wasn't recognized that
such dependency relationships were required even for a non-POD type A,
in order that this movability/destroyability calculation could
be done correctly for type A.

This change ensures that A always depends on B irrespective of
whether A is POD or non-POD.

This is a fairly significant change to our dependency relationships.
  • Loading branch information
adetaylor committed Nov 3, 2022
1 parent 04eab32 commit 4eab29a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions engine/src/conversion/analysis/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ impl HasDependencies for Api<FnPrePhase1> {
..
} => Box::new(old_tyname.iter().chain(deps.iter())),
Api::Struct {
analysis:
PodAnalysis {
kind: TypeKind::Pod,
bases,
field_deps,
..
},
analysis: PodAnalysis {
bases, field_deps, ..
},
..
} => Box::new(field_deps.iter().chain(bases.iter())),
Api::Function { analysis, .. } => Box::new(analysis.deps.iter()),
Expand Down

0 comments on commit 4eab29a

Please sign in to comment.