Skip to content

Commit

Permalink
do not recurse, simply stop looking at Option
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpesp committed Mar 16, 2022
1 parent bc4a146 commit 6b34cc6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions typify-impl/src/lib.rs
Expand Up @@ -269,7 +269,20 @@ impl TypeSpace {
.clone();
} else {
let mut child_type_entry = self.id_to_entry.get_mut(&child_type_id).unwrap().clone();
self.break_trivial_cyclic_refs(&parent_type_id, &mut child_type_entry, box_id);

match &mut child_type_entry.details {
// Look for the case where an option refers to the parent type
TypeEntryDetails::Option(option_type_id) => {
if *option_type_id == *parent_type_id {
*option_type_id = box_id
.get_or_insert_with(|| self.id_to_box(parent_type_id))
.clone();
}
}

_ => {}
}

let _ = self
.id_to_entry
.insert(child_type_id.clone(), child_type_entry);
Expand All @@ -283,11 +296,6 @@ impl TypeSpace {
box_id: &mut Option<TypeId>,
) {
match &mut type_entry.details {
// Look for the case where an option refers to the parent type
TypeEntryDetails::Option(option_type_id) => {
self.check_for_cyclic_ref(parent_type_id, option_type_id, box_id);
}

// Look for the case where a struct property refers to the parent
// type
TypeEntryDetails::Struct(s) => {
Expand Down

0 comments on commit 6b34cc6

Please sign in to comment.