Skip to content

Commit

Permalink
fix: condition reversed by wrong clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowee committed Jun 22, 2023
1 parent 586a517 commit ad87718
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/inferrer/unioner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ impl<'a, T: ITypeArena> UnionerClosure<'a, T> {
.expect("The type should be present in the arena during unioning")
{
Type::Union(_) => {
let Union { name_hints, types } = if let Some(..) = first_union {
first_union = Some(r#type);
mem::take(self.arena.get_mut(r#type).unwrap())
.into_union()
.unwrap()
} else {
let Union { name_hints, types } = if let Some(first_union) = first_union {
self.arena
.remove_in_favor_of(r#type, first_union.unwrap())
.remove_in_favor_of(r#type, first_union)
.unwrap()
.into_union()
.unwrap() // remove & expand the union
} else {
first_union = Some(r#type);
mem::take(self.arena.get_mut(r#type).unwrap())
.into_union()
.unwrap()
};
union_name_hints.extend(name_hints.into_inner());
types.into_iter().collect::<Vec<_>>()
Expand All @@ -80,21 +80,22 @@ impl<'a, T: ITypeArena> UnionerClosure<'a, T> {
match *self.arena.get(r#type).unwrap() {
Type::Map(_) => {
let map;
if let Some(..) = first_map {
// If this is the first map in the union, just take its inner out so that
// its slot can be reused again with ArenaIndex left intact.
first_map = Some(r#type);
map = mem::take(self.arena.get_mut(r#type).unwrap())
.into_map()
.unwrap();
} else {
// O.W., just remove the type from the arena.
if let Some(first_map) = first_map {
// If it is not the first map in the union, just remove the type from the
// arena.
map = self
.arena
.remove_in_favor_of(r#type, first_map.unwrap())
.remove_in_favor_of(r#type, first_map)
.unwrap()
.into_map()
.unwrap();
} else {
// O.W., just take the inner of the first map out so that its slot can be
// reused again with ArenaIndex left intact.
first_map = Some(r#type);
map = mem::take(self.arena.get_mut(r#type).unwrap())
.into_map()
.unwrap();
}
let maps = maps.get_or_insert_with(Default::default);
for (key, r#type) in map.fields.into_iter() {
Expand Down

0 comments on commit ad87718

Please sign in to comment.