Fix inhabitedness of non-exhaustive variants.
This commit ensures that non-exhaustive variants are considered inhabited when used in extern crates.
This commit is contained in:
parent
0db087e684
commit
0d034a2e4d
3 changed files with 32 additions and 8 deletions
|
|
@ -134,9 +134,14 @@ impl<'a, 'gcx, 'tcx> VariantDef {
|
|||
AdtKind::Enum => true,
|
||||
AdtKind::Struct => false,
|
||||
};
|
||||
DefIdForest::union(tcx, self.fields.iter().map(|f| {
|
||||
f.uninhabited_from(tcx, substs, is_enum)
|
||||
}))
|
||||
// Non-exhaustive variants from other crates are always considered inhabited.
|
||||
if self.is_field_list_non_exhaustive() && !self.def_id.is_local() {
|
||||
DefIdForest::empty()
|
||||
} else {
|
||||
DefIdForest::union(tcx, self.fields.iter().map(|f| {
|
||||
f.uninhabited_from(tcx, substs, is_enum)
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue