From 65732ee4b6c02f5f14cc01bedc3fb8c735a685e3 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 18 Sep 2024 21:08:52 -0700 Subject: [PATCH] review comments --- crates/red_knot_python_semantic/src/types/builder.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/red_knot_python_semantic/src/types/builder.rs b/crates/red_knot_python_semantic/src/types/builder.rs index b4b57aff8fe3f5..1224bd8ab65275 100644 --- a/crates/red_knot_python_semantic/src/types/builder.rs +++ b/crates/red_knot_python_semantic/src/types/builder.rs @@ -52,11 +52,10 @@ impl<'db> UnionBuilder<'db> { } Type::Never => {} _ => { - let mut add = true; let mut remove = vec![]; for element in &self.elements { if ty.is_subtype_of(self.db, *element) { - add = false; + return self; } else if element.is_subtype_of(self.db, ty) { remove.push(*element); } @@ -64,9 +63,7 @@ impl<'db> UnionBuilder<'db> { for element in remove { self.elements.remove(&element); } - if add { - self.elements.insert(ty); - } + self.elements.insert(ty); } }