Apply suggestions from code review

Co-authored-by: varkor <github@varkor.com>
This commit is contained in:
Nadrieril 2020-11-13 23:18:55 +00:00 committed by Nadrieril
parent b9da2b372f
commit 36e3409f67
3 changed files with 4 additions and 4 deletions

View file

@ -1588,7 +1588,7 @@ fn all_constructors<'p, 'tcx>(pcx: PatCtxt<'_, 'p, 'tcx>) -> Vec<Constructor<'tc
let is_declared_nonexhaustive = cx.is_foreign_non_exhaustive_enum(pcx.ty);
// If `exhaustive_patterns` is disabled and our scrutinee is an empty enum, we treat it
// as though it had an "unknown" constructor to avoid exposing its emptyness. The
// as though it had an "unknown" constructor to avoid exposing its emptiness. The
// exception is if the pattern is at the top level, because we want empty matches to be
// considered exhaustive.
let is_secretly_empty = def.variants.is_empty()
@ -1640,7 +1640,7 @@ fn all_constructors<'p, 'tcx>(pcx: PatCtxt<'_, 'p, 'tcx>) -> Vec<Constructor<'tc
vec![make_range(0, max)]
}
// If `exhaustive_patterns` is disabled and our scrutinee is the never type, we cannot
// expose its emptyness. The exception is if the pattern is at the top level, because we
// expose its emptiness. The exception is if the pattern is at the top level, because we
// want empty matches to be considered exhaustive.
ty::Never if !cx.tcx.features().exhaustive_patterns && !pcx.is_top_level => {
vec![NonExhaustive]

View file

@ -25,7 +25,7 @@ pub enum EmptyNonExhaustiveEnum {}
fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) {
match x {}
match x {
_ => {}, //~ ERROR unreachable pattern
_ => {} //~ ERROR unreachable pattern
}
}

View file

@ -1,7 +1,7 @@
error: unreachable pattern
--> $DIR/enum_same_crate_empty_match.rs:28:9
|
LL | _ => {},
LL | _ => {}
| ^
|
note: the lint level is defined here