diff --git a/crates/ty_python_semantic/src/types/narrow.rs b/crates/ty_python_semantic/src/types/narrow.rs index 59cf6b7589..6a044e3e13 100644 --- a/crates/ty_python_semantic/src/types/narrow.rs +++ b/crates/ty_python_semantic/src/types/narrow.rs @@ -1037,8 +1037,8 @@ impl<'db, 'ast> NarrowingConstraintsBuilder<'db, 'ast> { && rhs_ty.is_singleton(self.db) { let is_positive_check = is_positive == (ops[0] == ast::CmpOp::Is); - let filtered: Vec<_> = union - .elements(self.db) + let union_elements = union.elements(self.db); + let filtered: Vec<_> = union_elements .iter() .filter(|elem| { elem.as_nominal_instance() @@ -1056,11 +1056,11 @@ impl<'db, 'ast> NarrowingConstraintsBuilder<'db, 'ast> { }) .copied() .collect(); - if filtered.len() < union.elements(self.db).len() { + if filtered.len() < union_elements.len() { let place = self.expect_place(&subscript_place_expr); constraints.insert( place, - NarrowingConstraint::regular(UnionType::from_elements(self.db, filtered)), + NarrowingConstraint::typeguard(UnionType::from_elements(self.db, filtered)), ); } } @@ -1741,8 +1741,8 @@ impl<'db, 'ast> NarrowingConstraintsBuilder<'db, 'ast> { } // Filter the union based on whether each tuple element at the index could match the rhs. - let filtered: Vec<_> = union - .elements(self.db) + let union_elements = union.elements(self.db); + let filtered: Vec<_> = union_elements .iter() .filter(|elem| { elem.as_nominal_instance() @@ -1762,11 +1762,11 @@ impl<'db, 'ast> NarrowingConstraintsBuilder<'db, 'ast> { .collect(); // Only create a constraint if we actually narrowed something. - if filtered.len() < union.elements(self.db).len() { + if filtered.len() < union_elements.len() { let place = self.expect_place(&subscript_place_expr); Some(( place, - NarrowingConstraint::regular(UnionType::from_elements(self.db, filtered)), + NarrowingConstraint::typeguard(UnionType::from_elements(self.db, filtered)), )) } else { None