Skip to content

Commit 44bbc38

Browse files
authored
Rollup merge of rust-lang#62261 - varkor:conservative_is_privately_uninhabited-subst, r=oli-obk
Take substs into account in `conservative_is_privately_uninhabited`
2 parents 1492b2d + 962bf69 commit 44bbc38

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/librustc/ty/sty.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1703,22 +1703,21 @@ impl<'tcx> TyS<'tcx> {
17031703
/// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero
17041704
/// size, to account for partial initialisation. See #49298 for details.)
17051705
pub fn conservative_is_privately_uninhabited(&self, tcx: TyCtxt<'tcx>) -> bool {
1706-
// FIXME(varkor): we can make this less conversative by substituting concrete
1707-
// type arguments.
17081706
match self.sty {
17091707
ty::Never => true,
17101708
ty::Adt(def, _) if def.is_union() => {
17111709
// For now, `union`s are never considered uninhabited.
17121710
false
17131711
}
1714-
ty::Adt(def, _) => {
1712+
ty::Adt(def, substs) => {
17151713
// Any ADT is uninhabited if either:
17161714
// (a) It has no variants (i.e. an empty `enum`);
17171715
// (b) Each of its variants (a single one in the case of a `struct`) has at least
17181716
// one uninhabited field.
17191717
def.variants.iter().all(|var| {
17201718
var.fields.iter().any(|field| {
1721-
tcx.type_of(field.did).conservative_is_privately_uninhabited(tcx)
1719+
tcx.type_of(field.did).subst(tcx, substs)
1720+
.conservative_is_privately_uninhabited(tcx)
17221721
})
17231722
})
17241723
}

0 commit comments

Comments
 (0)