Skip to content

Commit c4ce73a

Browse files
committed
Review findings
1 parent 3837b2b commit c4ce73a

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

crates/ty_python_semantic/resources/mdtest/statically_known_branches.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,8 +1567,7 @@ from module import symbol
15671567
## Non-definitely bound symbols in conditions
15681568

15691569
When a non-definitely bound symbol is used as a (part of a) condition, we always infer an ambiguous
1570-
truthiness. If we wouldn't do that, `x` would be considered definitely bound in the following
1571-
example:
1570+
truthiness. If we didn't do that, `x` would be considered definitely bound in the following example:
15721571

15731572
```py
15741573
def _(flag: bool):

crates/ty_python_semantic/src/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'db> Place<'db> {
136136
}
137137
}
138138

139-
pub(crate) fn is_definitely_bound(&self) -> bool {
139+
pub(crate) const fn is_definitely_bound(&self) -> bool {
140140
matches!(self, Place::Type(_, Boundness::Bound))
141141
}
142142
}

crates/ty_python_semantic/src/types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8624,7 +8624,7 @@ impl TypeRelation {
86248624
}
86258625
}
86268626

8627-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
8627+
#[derive(Debug, Copy, Clone, PartialEq, Eq, get_size2::GetSize)]
86288628
pub enum Truthiness {
86298629
/// For an object `x`, `bool(x)` will always return `True`
86308630
AlwaysTrue,
@@ -8634,8 +8634,6 @@ pub enum Truthiness {
86348634
Ambiguous,
86358635
}
86368636

8637-
impl get_size2::GetSize for Truthiness {}
8638-
86398637
impl Truthiness {
86408638
pub(crate) const fn is_ambiguous(self) -> bool {
86418639
matches!(self, Truthiness::Ambiguous)

crates/ty_python_semantic/src/types/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn single_expression_cycle_initial<'db>(
339339

340340
/// Returns the statically-known truthiness of a given expression.
341341
///
342-
/// Returns `Truthiness::Ambiguous` in case any non-definitely bound places
342+
/// Returns [`Truthiness::Ambiguous`] in case any non-definitely bound places
343343
/// were encountered while inferring the type of the expression.
344344
#[salsa::tracked(cycle_fn=static_expression_truthiness_cycle_recover, cycle_initial=static_expression_truthiness_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)]
345345
pub(crate) fn static_expression_truthiness<'db>(

0 commit comments

Comments
 (0)