File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed
src/librustc_mir/hair/pattern Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -1267,23 +1267,14 @@ fn all_constructors<'a, 'tcx>(
1267
1267
let is_declared_nonexhaustive =
1268
1268
def. is_variant_list_non_exhaustive ( ) && !cx. is_local ( pcx. ty ) ;
1269
1269
1270
- // If our scrutinee is *privately* an empty enum, we must treat it as though it had
1271
- // an "unknown" constructor (in that case, all other patterns obviously can't be
1272
- // variants) to avoid exposing its emptyness. See the `match_privately_empty` test
1273
- // for details.
1274
- let is_privately_empty = if cx. tcx . features ( ) . exhaustive_patterns {
1275
- // This cannot happen because we have already filtered out uninhabited variants.
1276
- false
1277
- } else {
1278
- // FIXME: this is fishy
1279
- def. variants . is_empty ( )
1280
- } ;
1281
-
1282
- if is_privately_empty || is_declared_nonexhaustive {
1283
- vec ! [ NonExhaustive ]
1284
- } else {
1285
- ctors
1286
- }
1270
+ // If `exhaustive_patterns` is disabled and our scrutinee is an empty enum, we treat it
1271
+ // as though it had an "unknown" constructor to avoid exposing its emptyness. Note that
1272
+ // an empty match will still be considered exhaustive because that case is handled
1273
+ // separately in `check_match`.
1274
+ let is_secretly_empty =
1275
+ def. variants . is_empty ( ) && !cx. tcx . features ( ) . exhaustive_patterns ;
1276
+
1277
+ if is_secretly_empty || is_declared_nonexhaustive { vec ! [ NonExhaustive ] } else { ctors }
1287
1278
}
1288
1279
ty:: Char => {
1289
1280
vec ! [
You can’t perform that action at this time.
0 commit comments