Skip to content

Commit

Permalink
Fix constructors for structs with enum fields.
Browse files Browse the repository at this point in the history
Fixes #1170.

Previously we were failing to identify that structs with enum fields
were movable. This led to compilation failures in cases where there
were APIs referring to Vec<SomeSuchStruct>, since we chose not to
impl CxxVector<SomeSuchStruct> as thought it was not movable.

This commit makes two changes to fix this:
* It considers that enums have implicit constructors.
* Previously, <Api as HasDependencies>::deps() was failing to list
  field or base dependencies for non-POD structs. This meant that
  depth_first failed to ensure that field types were considered
  prior to a struct in analyzing such implicit constructors.
  Normally this doesn't matter because types must be declared
  first, but in the case of nested or incomplete types this could
  have led to a faulty analysis.
  • Loading branch information
adetaylor committed Oct 24, 2022
1 parent 782d136 commit 1127a1e
Show file tree
Hide file tree
Showing 2 changed files with 357 additions and 327 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
Loading

0 comments on commit 1127a1e

Please sign in to comment.