- fn uninhabited_from(
- &self,
- tcx: TyCtxt<'a, 'gcx, 'tcx>,
- substs: SubstsRef<'tcx>) -> DefIdForest
- {
- DefIdForest::intersection(tcx, self.variants.iter().map(|v| {
- v.uninhabited_from(tcx, substs, self.adt_kind())
- }))
+ fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> DefIdForest {
+ // Non-exhaustive ADTs from other crates are always considered inhabited.
+ if self.is_variant_list_non_exhaustive() && !self.did.is_local() {
+ DefIdForest::empty()
+ } else {
+ DefIdForest::intersection(tcx, self.variants.iter().map(|v| {
+ v.uninhabited_from(tcx, substs, self.adt_kind())
+ }))
+ }