Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1fa9d5e

Browse files
committed
Correct visibility check
1 parent 1a580a3 commit 1fa9d5e

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

crates/hir-ty/src/inhabitedness.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,11 @@ impl UninhabitedFrom<'_> {
149149
subst: &Substitution,
150150
is_enum: bool,
151151
) -> ControlFlow<VisiblyUninhabited> {
152-
let target_mod = self.target_mod;
153-
let mut data_uninhabitedness =
154-
|| ty.clone().substitute(Interner, subst).visit_with(self, DebruijnIndex::INNERMOST);
155-
if is_enum {
156-
data_uninhabitedness()
152+
if is_enum || vis.is_visible_from(self.db.upcast(), self.target_mod) {
153+
let ty = ty.clone().substitute(Interner, subst);
154+
ty.visit_with(self, DebruijnIndex::INNERMOST)
157155
} else {
158-
match vis {
159-
Visibility::Module(mod_id) if mod_id == target_mod => data_uninhabitedness(),
160-
Visibility::Module(_) => CONTINUE_OPAQUELY_INHABITED,
161-
Visibility::Public => data_uninhabitedness(),
162-
}
156+
CONTINUE_OPAQUELY_INHABITED
163157
}
164158
}
165159
}

0 commit comments

Comments
 (0)