@@ -840,7 +840,6 @@ fn place_from_bindings_impl<'db>(
840
840
} ) if binding. is_undefined_or ( is_non_exported) => Some ( * reachability_constraint) ,
841
841
_ => None ,
842
842
} ;
843
- let mut all_bindings_definitely_reachable = true ;
844
843
let mut deleted_reachability = Truthiness :: AlwaysFalse ;
845
844
846
845
// Evaluate this lazily because we don't always need it (for example, if there are no visible
@@ -933,8 +932,6 @@ fn place_from_bindings_impl<'db>(
933
932
}
934
933
935
934
let binding_ty = binding_type ( db, binding) ;
936
- all_bindings_definitely_reachable =
937
- all_bindings_definitely_reachable && static_reachability. is_always_true ( ) ;
938
935
Some ( narrowing_constraint. narrow ( db, binding_ty, binding. place ( db) ) )
939
936
} ,
940
937
) ;
@@ -947,13 +944,7 @@ fn place_from_bindings_impl<'db>(
947
944
} ;
948
945
949
946
let boundness = match boundness_analysis {
950
- BoundnessAnalysis :: AlwaysBound => {
951
- if all_bindings_definitely_reachable {
952
- Boundness :: Bound
953
- } else {
954
- Boundness :: PossiblyUnbound
955
- }
956
- }
947
+ BoundnessAnalysis :: AlwaysBound => Boundness :: Bound ,
957
948
BoundnessAnalysis :: BasedOnUnboundVisibility => match unbound_visibility ( ) {
958
949
Some ( Truthiness :: AlwaysTrue ) => {
959
950
unreachable ! (
@@ -1135,6 +1126,10 @@ fn place_from_declarations_impl<'db>(
1135
1126
if all_declarations_definitely_reachable {
1136
1127
Boundness :: Bound
1137
1128
} else {
1129
+ // For declarations, it is important to consider the possibility that they might only
1130
+ // be bound in one control flow path, while the other path contains a binding. In order
1131
+ // to even consider the bindings as well in `place_by_id`, we return `PossiblyUnbound`
1132
+ // here.
1138
1133
Boundness :: PossiblyUnbound
1139
1134
}
1140
1135
}
0 commit comments