diff options
| author | Andrew Cann <shum@canndrew.org> | 2016-12-11 23:47:51 +0800 |
|---|---|---|
| committer | Andrew Cann <shum@canndrew.org> | 2017-01-03 15:48:29 +0800 |
| commit | 44a70f0221819f3db2c845baf555835d9532f29f (patch) | |
| tree | b26e6a16cd2cfd99971f8e3e14fb036871756f62 | |
| parent | 7946597f7556dc8e1ad05e02d7e82b4ff800a5ac (diff) | |
Fix inhabitedness bug
| -rw-r--r-- | src/librustc/ty/inhabitedness.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/librustc/ty/inhabitedness.rs b/src/librustc/ty/inhabitedness.rs index 54fdbe1a34a..5acffca2679 100644 --- a/src/librustc/ty/inhabitedness.rs +++ b/src/librustc/ty/inhabitedness.rs @@ -186,18 +186,19 @@ impl<'a, 'gcx, 'tcx> FieldDef { substs: &'tcx Substs<'tcx>, is_enum: bool) -> NodeForrest { - if let Visibility::PrivateExternal = self.vis { - return NodeForrest::empty(); - } - - let data_inhabitedness = self.ty(tcx, substs).uninhabited_from(visited, tcx); - match self.vis { - Visibility::Restricted(from) if !is_enum => { - let node_set = NodeForrest::from_node(from); - let iter = Some(node_set).into_iter().chain(Some(data_inhabitedness)); - NodeForrest::intersection(tcx, iter) - }, - _ => data_inhabitedness, + let mut data_uninhabitedness = move || self.ty(tcx, substs).uninhabited_from(visited, tcx); + if is_enum { + data_uninhabitedness() + } else { + match self.vis { + Visibility::PrivateExternal => NodeForrest::empty(), + Visibility::Restricted(from) => { + let node_set = NodeForrest::from_node(from); + let iter = Some(node_set).into_iter().chain(Some(data_uninhabitedness())); + NodeForrest::intersection(tcx, iter) + }, + Visibility::Public => data_uninhabitedness(), + } } } } |
