Skip to content

Commit 44a70f0

Browse files
committed
Fix inhabitedness bug
1 parent 7946597 commit 44a70f0

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/librustc/ty/inhabitedness.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,19 @@ impl<'a, 'gcx, 'tcx> FieldDef {
186186
substs: &'tcx Substs<'tcx>,
187187
is_enum: bool) -> NodeForrest
188188
{
189-
if let Visibility::PrivateExternal = self.vis {
190-
return NodeForrest::empty();
191-
}
192-
193-
let data_inhabitedness = self.ty(tcx, substs).uninhabited_from(visited, tcx);
194-
match self.vis {
195-
Visibility::Restricted(from) if !is_enum => {
196-
let node_set = NodeForrest::from_node(from);
197-
let iter = Some(node_set).into_iter().chain(Some(data_inhabitedness));
198-
NodeForrest::intersection(tcx, iter)
199-
},
200-
_ => data_inhabitedness,
189+
let mut data_uninhabitedness = move || self.ty(tcx, substs).uninhabited_from(visited, tcx);
190+
if is_enum {
191+
data_uninhabitedness()
192+
} else {
193+
match self.vis {
194+
Visibility::PrivateExternal => NodeForrest::empty(),
195+
Visibility::Restricted(from) => {
196+
let node_set = NodeForrest::from_node(from);
197+
let iter = Some(node_set).into_iter().chain(Some(data_uninhabitedness()));
198+
NodeForrest::intersection(tcx, iter)
199+
},
200+
Visibility::Public => data_uninhabitedness(),
201+
}
201202
}
202203
}
203204
}

0 commit comments

Comments
 (0)