Dont consider fields that are forced unstable due to -Zforce-unstable-if-unmarked to be uninhabited
This commit is contained in:
parent
f6107ca173
commit
0a6a0e47d2
5 changed files with 43 additions and 7 deletions
|
@ -43,6 +43,7 @@
|
|||
//! This code should only compile in modules where the uninhabitedness of `Foo`
|
||||
//! is visible.
|
||||
|
||||
use rustc_span::sym;
|
||||
use rustc_type_ir::TyKind::*;
|
||||
use tracing::instrument;
|
||||
|
||||
|
@ -90,7 +91,13 @@ impl<'tcx> VariantDef {
|
|||
// `let pred = pred.or(InhabitedPredicate::IsUnstable(field.did));`
|
||||
// but this is unnecessary for now, since it would only affect nightly-only
|
||||
// code or code within the standard library itself.
|
||||
if tcx.lookup_stability(field.did).is_some_and(|stab| stab.is_unstable()) {
|
||||
// HACK: We filter out `rustc_private` fields since with the flag
|
||||
// `-Zforce-unstable-if-unmarked` we consider all unmarked fields to be
|
||||
// unstable when building the compiler.
|
||||
if tcx
|
||||
.lookup_stability(field.did)
|
||||
.is_some_and(|stab| stab.is_unstable() && stab.feature != sym::rustc_private)
|
||||
{
|
||||
return InhabitedPredicate::True;
|
||||
}
|
||||
let pred = tcx.type_of(field.did).instantiate_identity().inhabited_predicate(tcx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue