From 4eab29a29a127a42d890bd8d91397c2ccc7d0fd2 Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Thu, 3 Nov 2022 10:15:03 +0000 Subject: [PATCH] Properly propagate deps for non-POD structs 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. --- engine/src/conversion/analysis/deps.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/engine/src/conversion/analysis/deps.rs b/engine/src/conversion/analysis/deps.rs index b75addf8c..a8519f2fa 100644 --- a/engine/src/conversion/analysis/deps.rs +++ b/engine/src/conversion/analysis/deps.rs @@ -37,13 +37,9 @@ impl HasDependencies for Api { .. } => 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()),