Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bacd80b

Browse files
committedJan 18, 2025·
Dont consider fields that are forced unstable due to -Zforce-unstable-if-unmarked to be uninhabited
1 parent 6e54386 commit bacd80b

File tree

1 file changed

+8
-1
lines changed
  • compiler/rustc_middle/src/ty/inhabitedness

1 file changed

+8
-1
lines changed
 

‎compiler/rustc_middle/src/ty/inhabitedness/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
//! This code should only compile in modules where the uninhabitedness of `Foo`
4444
//! is visible.
4545
46+
use rustc_span::sym;
4647
use rustc_type_ir::TyKind::*;
4748
use tracing::instrument;
4849

@@ -90,7 +91,13 @@ impl<'tcx> VariantDef {
9091
// `let pred = pred.or(InhabitedPredicate::IsUnstable(field.did));`
9192
// but this is unnecessary for now, since it would only affect nightly-only
9293
// code or code within the standard library itself.
93-
if tcx.lookup_stability(field.did).is_some_and(|stab| stab.is_unstable()) {
94+
// HACK: We filter out `rustc_private` fields since with the flag
95+
// `-Zforce-unstable-if-unmarked` we consider all unmarked fields to be
96+
// unstable when building the compiler.
97+
if tcx
98+
.lookup_stability(field.did)
99+
.is_some_and(|stab| stab.is_unstable() && stab.feature != sym::rustc_private)
100+
{
94101
return InhabitedPredicate::True;
95102
}
96103
let pred = tcx.type_of(field.did).instantiate_identity().inhabited_predicate(tcx);

0 commit comments

Comments
 (0)
Please sign in to comment.