File tree 4 files changed +38
-2
lines changed
compiler/rustc_middle/src/ty/inhabitedness
4 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 43
43
//! This code should only compile in modules where the uninhabitedness of `Foo`
44
44
//! is visible.
45
45
46
+ use rustc_span:: sym;
46
47
use rustc_type_ir:: TyKind :: * ;
47
48
use tracing:: instrument;
48
49
@@ -90,7 +91,13 @@ impl<'tcx> VariantDef {
90
91
// `let pred = pred.or(InhabitedPredicate::IsUnstable(field.did));`
91
92
// but this is unnecessary for now, since it would only affect nightly-only
92
93
// 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
+ {
94
101
return InhabitedPredicate :: True ;
95
102
}
96
103
let pred = tcx. type_of ( field. did ) . instantiate_identity ( ) . inhabited_predicate ( tcx) ;
Original file line number Diff line number Diff line change
1
+ use std:: pin:: Pin ;
2
+
3
+ enum Void { }
4
+
5
+ fn demo ( x : Pin < Void > ) {
6
+ match x { }
7
+ //~^ ERROR non-exhaustive patterns
8
+ }
9
+
10
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0004]: non-exhaustive patterns: type `Pin<Void>` is non-empty
2
+ --> $DIR/uninhabited-pin-field.rs:6:11
3
+ |
4
+ LL | match x {}
5
+ | ^
6
+ |
7
+ note: `Pin<Void>` defined here
8
+ --> $SRC_DIR/core/src/pin.rs:LL:COL
9
+ = note: the matched value is of type `Pin<Void>`
10
+ help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
11
+ |
12
+ LL ~ match x {
13
+ LL + _ => todo!(),
14
+ LL ~ }
15
+ |
16
+
17
+ error: aborting due to 1 previous error
18
+
19
+ For more information about this error, try `rustc --explain E0004`.
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit
14
14
|
15
15
LL ~ match x {
16
16
LL + _ => todo!(),
17
- LL + }
17
+ LL ~ }
18
18
|
19
19
20
20
error: aborting due to 1 previous error
You can’t perform that action at this time.
0 commit comments