Auto merge of #122792 - Nadrieril:stabilize-min-exh-pats2, r=fee1-dead

Stabilize `min_exhaustive_patterns`

## Stabilisation report

I propose we stabilize the [`min_exhaustive_patterns`](https://github.com/rust-lang/rust/issues/119612) language feature.

With this feature, patterns of empty types are considered unreachable when matched by-value. This allows:
```rust
enum Void {}
fn foo() -> Result<u32, Void>;

fn main() {
  let Ok(x) = foo();
  // also
  match foo() {
    Ok(x) => ...,
  }
}
```

This is a subset of the long-unstable [`exhaustive_patterns`](https://github.com/rust-lang/rust/issues/51085) feature. That feature is blocked because omitting empty patterns is tricky when *not* matched by-value. This PR stabilizes the by-value case, which is not tricky.

The not-by-value cases (behind references, pointers, and unions) stay as they are today, e.g.
```rust
enum Void {}
fn foo() -> Result<u32, &Void>;

fn main() {
  let Ok(x) = foo(); // ERROR: missing `Err(_)`
}
```

The consequence on existing code is some extra "unreachable pattern" warnings. This is fully backwards-compatible.

### Comparison with today's rust

This proposal only affects match checking of empty types (i.e. types with no valid values). Non-empty types behave the same with or without this feature. Note that everything below is phrased in terms of `match` but applies equallly to `if let` and other pattern-matching expressions.

To be precise, a visibly empty type is:
- an enum with no variants;
- the never type `!`;
- a struct with a *visible* field of a visibly empty type (and no #[non_exhaustive] annotation);
- a tuple where one of the types is visibly empty;
- en enum with all variants visibly empty (and no `#[non_exhaustive]` annotation);
- a `[T; N]` with `N != 0` and `T` visibly empty;
- all other types are nonempty.

(An extra change was proposed below: that we ignore #[non_exhaustive] for structs since adding fields cannot turn an empty struct into a non-empty one)

For normal types, exhaustiveness checking requires that we list all variants (or use a wildcard). For empty types it's more subtle: in some cases we require a `_` pattern even though there are no valid values that can match it. This is where the difference lies regarding this feature.

#### Today's rust

Under today's rust, a `_` is required for all empty types, except specifically: if the matched expression is of type `!` (the never type) or `EmptyEnum` (where `EmptyEnum` is an enum with no variants), then the `_` is not required.

```rust
let foo: Result<u32, !> = ...;
match foo {
    Ok(x) => ...,
    Err(_) => ..., // required
}
let foo: Result<u32, &!> = ...;
match foo {
    Ok(x) => ...,
    Err(_) => ..., // required
}
let foo: &! = ...;
match foo {
    _ => ..., // required
}
fn blah(foo: (u32, !)) {
    match foo {
        _ => ..., // required
    }
}
unsafe {
    let ptr: *const ! = ...;
    match *ptr {} // allowed
    let ptr: *const (u32, !) = ...;
    match *ptr {
        (x, _) => { ... } // required
    }
    let ptr: *const Result<u32, !> = ...;
    match *ptr {
        Ok(x) => { ... }
        Err(_) => { ... } // required
    }
}
```

#### After this PR

After this PR, a pattern of an empty type can be omitted if (and only if):
- the match scrutinee expression has type  `!` or `EmptyEnum` (like before);
- *or* the empty type is matched by value (that's the new behavior).

In all other cases, a `_` is required to match on an empty type.

```rust
let foo: Result<u32, !> = ...;
match foo {
    Ok(x) => ..., // `Err` not required
}
let foo: Result<u32, &!> = ...;
match foo {
    Ok(x) => ...,
    Err(_) => ..., // required because `!` is under a dereference
}
let foo: &! = ...;
match foo {
    _ => ..., // required because `!` is under a dereference
}
fn blah(foo: (u32, !)) {
    match foo {} // allowed
}
unsafe {
    let ptr: *const ! = ...;
    match *ptr {} // allowed
    let ptr: *const (u32, !) = ...;
    match *ptr {
        (x, _) => { ... } // required because the matched place is under a (pointer) dereference
    }
    let ptr: *const Result<u32, !> = ...;
    match *ptr {
        Ok(x) => { ... }
        Err(_) => { ... } // required because the matched place is under a (pointer) dereference
    }
}
```

### Documentation

The reference does not say anything specific about exhaustiveness checking, hence there is nothing to update there. The nomicon does, I opened https://github.com/rust-lang/nomicon/pull/445 to reflect the changes.

### Tests

The relevant tests are in `tests/ui/pattern/usefulness/empty-types.rs`.

### Unresolved Questions

None that I know of.

try-job: dist-aarch64-apple
This commit is contained in:
bors 2024-08-10 12:48:29 +00:00
commit 8291d68d92
100 changed files with 1131 additions and 1005 deletions

View File

@ -585,6 +585,7 @@ pub enum E2<X> {
V4,
}
#[allow(unreachable_patterns)]
fn check_niche_behavior() {
if let E1::V2 { .. } = (E1::V1 { f: true }) {
intrinsics::abort();

View File

@ -430,6 +430,7 @@ pub enum E2<X> {
V4,
}
#[allow(unreachable_patterns)]
fn check_niche_behavior () {
if let E1::V2 { .. } = (E1::V1 { f: true }) {
intrinsics::abort();

View File

@ -66,6 +66,7 @@ macro_rules! into_diag_arg_for_number {
impl IntoDiagArg for $ty {
fn into_diag_arg(self) -> DiagArgValue {
// Convert to a string if it won't fit into `Number`.
#[allow(irrefutable_let_patterns)]
if let Ok(n) = TryInto::<i32>::try_into(self) {
DiagArgValue::Number(n)
} else {

View File

@ -267,6 +267,8 @@ declare_features! (
(accepted, min_const_generics, "1.51.0", Some(74878)),
/// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions.
(accepted, min_const_unsafe_fn, "1.33.0", Some(55607)),
/// Allows exhaustive pattern matching on uninhabited types when matched by value.
(accepted, min_exhaustive_patterns, "CURRENT_RUSTC_VERSION", Some(119612)),
/// Allows using `Self` and associated types in struct expressions and patterns.
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
/// Allows using the MOVBE target feature.

View File

@ -519,9 +519,6 @@ declare_features! (
(unstable, macro_metavar_expr_concat, "1.81.0", Some(124225)),
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
(unstable, marker_trait_attr, "1.30.0", Some(29864)),
/// Allows exhaustive pattern matching on types that contain uninhabited types in cases that are
/// unambiguously sound.
(unstable, min_exhaustive_patterns, "1.77.0", Some(119612)),
/// A minimal, sound subset of specialization intended to be used by the
/// standard library until the soundness issues with specialization
/// are fixed.

View File

@ -28,6 +28,7 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::potential_query_instability)]
#![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(allocator_api)]
@ -48,7 +49,6 @@
#![feature(iter_from_coroutine)]
#![feature(let_chains)]
#![feature(macro_metavar_expr)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(never_type)]

View File

@ -208,14 +208,11 @@ impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
subpairs = cx.field_match_pairs(downcast_place, subpatterns);
let irrefutable = adt_def.variants().iter_enumerated().all(|(i, v)| {
i == variant_index || {
(cx.tcx.features().exhaustive_patterns
|| cx.tcx.features().min_exhaustive_patterns)
&& !v
.inhabited_predicate(cx.tcx, adt_def)
.instantiate(cx.tcx, args)
.apply_ignore_module(cx.tcx, cx.param_env)
}
i == variant_index
|| !v
.inhabited_predicate(cx.tcx, adt_def)
.instantiate(cx.tcx, args)
.apply_ignore_module(cx.tcx, cx.param_env)
}) && (adt_def.did().is_local()
|| !adt_def.is_variant_list_non_exhaustive());
if irrefutable {

View File

@ -695,9 +695,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
// Emit an extra note if the first uncovered witness would be uninhabited
// if we disregard visibility.
let witness_1_is_privately_uninhabited = if (self.tcx.features().exhaustive_patterns
|| self.tcx.features().min_exhaustive_patterns)
&& let Some(witness_1) = witnesses.get(0)
let witness_1_is_privately_uninhabited = if let Some(witness_1) = witnesses.get(0)
&& let ty::Adt(adt, args) = witness_1.ty().kind()
&& adt.is_enum()
&& let Constructor::Variant(variant_index) = witness_1.ctor()
@ -1059,7 +1057,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
err.note("`&str` cannot be matched exhaustively, so a wildcard `_` is necessary");
} else if cx.is_foreign_non_exhaustive_enum(ty) {
err.note(format!("`{ty}` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively"));
} else if cx.is_uninhabited(ty.inner()) && cx.tcx.features().min_exhaustive_patterns {
} else if cx.is_uninhabited(ty.inner()) {
// The type is uninhabited yet there is a witness: we must be in the `MaybeInvalid`
// case.
err.note(format!("`{ty}` is uninhabited but is not being matched by value, so a wildcard `_` is required"));

View File

@ -54,7 +54,6 @@ pub trait PatCx: Sized + fmt::Debug {
type PatData: Clone;
fn is_exhaustive_patterns_feature_on(&self) -> bool;
fn is_min_exhaustive_patterns_feature_on(&self) -> bool;
/// The number of fields for this constructor.
fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize;

View File

@ -237,9 +237,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
let tys = cx.variant_sub_tys(ty, variant).map(|(field, ty)| {
let is_visible =
adt.is_enum() || field.vis.is_accessible_from(cx.module, cx.tcx);
let is_uninhabited = (cx.tcx.features().exhaustive_patterns
|| cx.tcx.features().min_exhaustive_patterns)
&& cx.is_uninhabited(*ty);
let is_uninhabited = cx.is_uninhabited(*ty);
let skip = is_uninhabited && (!is_visible || is_non_exhaustive);
(ty, PrivateUninhabitedField(skip))
});
@ -925,9 +923,6 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> {
fn is_exhaustive_patterns_feature_on(&self) -> bool {
self.tcx.features().exhaustive_patterns
}
fn is_min_exhaustive_patterns_feature_on(&self) -> bool {
self.tcx.features().min_exhaustive_patterns
}
fn ctor_arity(&self, ctor: &crate::constructor::Constructor<Self>, ty: &Self::Ty) -> usize {
self.ctor_arity(ctor, *ty)

View File

@ -543,13 +543,11 @@
//! recurse into subpatterns. That second part is done through [`PlaceValidity`], most notably
//! [`PlaceValidity::specialize`].
//!
//! Having said all that, in practice we don't fully follow what's been presented in this section.
//! Let's call "toplevel exception" the case where the match scrutinee itself has type `!` or
//! `EmptyEnum`. First, on stable rust, we require `_` patterns for empty types in all cases apart
//! from the toplevel exception. The `exhaustive_patterns` and `min_exaustive_patterns` allow
//! omitting patterns in the cases described above. There's a final detail: in the toplevel
//! exception or with the `exhaustive_patterns` feature, we ignore place validity when checking
//! whether a pattern is required for exhaustiveness. I (Nadrieril) hope to deprecate this behavior.
//! Having said all that, we don't fully follow what's been presented in this section. For
//! backwards-compatibility, we ignore place validity when checking whether a pattern is required
//! for exhaustiveness in two cases: when the `exhaustive_patterns` feature gate is on, or when the
//! match scrutinee itself has type `!` or `EmptyEnum`. I (Nadrieril) hope to deprecate this
//! exception.
//!
//!
//!
@ -953,13 +951,10 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
self.is_scrutinee && matches!(ctors_for_ty, ConstructorSet::NoConstructors);
// Whether empty patterns are counted as useful or not. We only warn an empty arm unreachable if
// it is guaranteed unreachable by the opsem (i.e. if the place is `known_valid`).
let empty_arms_are_unreachable = self.validity.is_known_valid()
&& (is_toplevel_exception
|| cx.is_exhaustive_patterns_feature_on()
|| cx.is_min_exhaustive_patterns_feature_on());
let empty_arms_are_unreachable = self.validity.is_known_valid();
// Whether empty patterns can be omitted for exhaustiveness. We ignore place validity in the
// toplevel exception and `exhaustive_patterns` cases for backwards compatibility.
let can_omit_empty_arms = empty_arms_are_unreachable
let can_omit_empty_arms = self.validity.is_known_valid()
|| is_toplevel_exception
|| cx.is_exhaustive_patterns_feature_on();

View File

@ -152,10 +152,6 @@ impl PatCx for Cx {
false
}
fn is_min_exhaustive_patterns_feature_on(&self) -> bool {
true
}
fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize {
ty.sub_tys(ctor).len()
}

View File

@ -9,12 +9,12 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(min_exhaustive_patterns)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
// tidy-alphabetical-end

View File

@ -87,6 +87,7 @@ where
pub(crate) fn from_tree(tree: Tree<!, R>) -> Result<Self, Uninhabited> {
Ok(match tree {
Tree::Byte(b) => Self::from_byte(b),
#[cfg(bootstrap)]
Tree::Def(..) => unreachable!(),
Tree::Ref(r) => Self::from_ref(r),
Tree::Alt(alts) => {

View File

@ -91,6 +91,7 @@ pub trait TypeFoldable<I: Interner>: TypeVisitable<I> {
fn fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self {
match self.try_fold_with(folder) {
Ok(t) => t,
#[cfg(bootstrap)]
Err(e) => match e {},
}
}
@ -115,6 +116,7 @@ pub trait TypeSuperFoldable<I: Interner>: TypeFoldable<I> {
fn super_fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self {
match self.try_super_fold_with(folder) {
Ok(t) => t,
#[cfg(bootstrap)]
Err(e) => match e {},
}
}

View File

@ -121,6 +121,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
{
match self.try_fold(init, |b, item| Ok::<B, !>(f(b, item))) {
Ok(b) => b,
#[cfg(bootstrap)]
Err(e) => match e {},
}
}
@ -242,6 +243,7 @@ impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A> {
{
match self.try_rfold(init, |b, item| Ok::<B, !>(f(b, item))) {
Ok(b) => b,
#[cfg(bootstrap)]
Err(e) => match e {},
}
}

View File

@ -192,6 +192,7 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
#![feature(allow_internal_unsafe)]
@ -225,7 +226,6 @@
#![feature(link_llvm_intrinsics)]
#![feature(macro_metavar_expr)]
#![feature(marker_trait_attr)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(multiple_supertrait_upcastable)]
#![feature(must_not_suspend)]

View File

@ -272,6 +272,7 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
#![feature(alloc_error_handler)]
#![feature(allocator_internals)]
#![feature(allow_internal_unsafe)]
@ -299,7 +300,6 @@
#![feature(link_cfg)]
#![feature(linkage)]
#![feature(macro_metavar_expr_concat)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(must_not_suspend)]
#![feature(needs_panic_runtime)]

View File

@ -2931,6 +2931,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU
moved_before_use,
same_ctxt,
},
#[allow(unreachable_patterns)]
Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow<!>"),
None => ExprUseCtxt {
node: Node::Crate(cx.tcx.hir().root_module()),

View File

@ -89,7 +89,7 @@ fn main() {
// lint here
use std::convert::Infallible;
if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else {
if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else {
println!("else block");
return;
}

View File

@ -98,7 +98,7 @@ fn main() {
// lint here
use std::convert::Infallible;
match Result::<i32, Infallible>::Ok(1) {
match Result::<i32, &Infallible>::Ok(1) {
Ok(a) => println!("${:?}", a),
Err(_) => {
println!("else block");

View File

@ -64,7 +64,7 @@ LL + }
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> tests/ui/single_match_else.rs:101:5
|
LL | / match Result::<i32, Infallible>::Ok(1) {
LL | / match Result::<i32, &Infallible>::Ok(1) {
LL | | Ok(a) => println!("${:?}", a),
LL | | Err(_) => {
LL | | println!("else block");
@ -75,7 +75,7 @@ LL | | }
|
help: try
|
LL ~ if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else {
LL ~ if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else {
LL + println!("else block");
LL + return;
LL + }

View File

@ -463,6 +463,7 @@ pub fn eval_entry<'tcx>(
let res = match res {
Err(res) => res,
// `Ok` can never happen
#[cfg(bootstrap)]
Ok(never) => match never {},
};

View File

@ -59,6 +59,7 @@ async fn hello_world() {
}
// This example comes from https://github.com/rust-lang/rust/issues/115145
#[allow(unreachable_patterns)]
async fn uninhabited_variant() {
async fn unreachable(_: Never) {}

View File

@ -43,6 +43,7 @@ fn discriminant_overflow() {
}
}
#[allow(unreachable_patterns)]
fn more_discriminant_overflow() {
pub enum Infallible {}

View File

@ -27,6 +27,7 @@ macro_rules! from_bytes {
($ty:tt, $value:expr) => {
($ty::from_le_bytes(match ($value).try_into() {
Ok(it) => it,
#[allow(unreachable_patterns)]
Err(_) => return Err(MirEvalError::InternalError("mismatched size".into())),
}))
};

View File

@ -1161,6 +1161,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
ProjectionElem::OpaqueCast(it) => {
ProjectionElem::OpaqueCast(it)
}
#[allow(unreachable_patterns)]
ProjectionElem::Index(it) => match it {},
})
.collect(),

View File

@ -13,17 +13,17 @@ fn opt1(_1: &Result<u32, Void>) -> &u32 {
bb0: {
PlaceMention(_1);
_2 = discriminant((*_1));
switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1];
falseEdge -> [real: bb4, imaginary: bb1];
}
bb1: {
FakeRead(ForMatchedPlace(None), _1);
unreachable;
_2 = discriminant((*_1));
switchInt(move _2) -> [1: bb3, otherwise: bb2];
}
bb2: {
falseEdge -> [real: bb4, imaginary: bb3];
FakeRead(ForMatchedPlace(None), _1);
unreachable;
}
bb3: {

View File

@ -11,25 +11,10 @@ fn opt2(_1: &Result<u32, Void>) -> &u32 {
bb0: {
PlaceMention(_1);
_2 = discriminant((*_1));
switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1];
}
bb1: {
FakeRead(ForMatchedPlace(None), _1);
unreachable;
}
bb2: {
StorageLive(_3);
_3 = &(((*_1) as Ok).0: u32);
_0 = &(*_3);
StorageDead(_3);
return;
}
bb3: {
FakeRead(ForMatchedPlace(None), (((*_1) as Err).0: Void));
unreachable;
}
}

View File

@ -12,24 +12,19 @@ fn opt3(_1: &Result<u32, Void>) -> &u32 {
bb0: {
PlaceMention(_1);
_2 = discriminant((*_1));
switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
switchInt(move _2) -> [1: bb2, otherwise: bb1];
}
bb1: {
FakeRead(ForMatchedPlace(None), _1);
unreachable;
}
bb2: {
FakeRead(ForMatchedPlace(None), (((*_1) as Err).0: Void));
unreachable;
}
bb3: {
StorageLive(_3);
_3 = &(((*_1) as Ok).0: u32);
_0 = &(*_3);
StorageDead(_3);
return;
}
bb2: {
FakeRead(ForMatchedPlace(None), (((*_1) as Err).0: Void));
unreachable;
}
}

View File

@ -19,14 +19,16 @@
bb1: {
_2 = discriminant(_1);
- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2];
+ _5 = Eq(_2, const 0_isize);
- switchInt(move _2) -> [1: bb3, otherwise: bb2];
+ _5 = Ne(_2, const 1_isize);
+ assume(move _5);
+ goto -> bb4;
+ goto -> bb2;
}
bb2: {
unreachable;
_0 = const ();
StorageDead(_1);
return;
}
bb3: {
@ -35,11 +37,5 @@
- StorageLive(_4);
unreachable;
}
bb4: {
_0 = const ();
StorageDead(_1);
return;
}
}

View File

@ -19,14 +19,16 @@
bb1: {
_2 = discriminant(_1);
- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2];
+ _5 = Eq(_2, const 0_isize);
- switchInt(move _2) -> [1: bb3, otherwise: bb2];
+ _5 = Ne(_2, const 1_isize);
+ assume(move _5);
+ goto -> bb4;
+ goto -> bb2;
}
bb2: {
unreachable;
_0 = const ();
StorageDead(_1);
return;
}
bb3: {
@ -35,11 +37,5 @@
- StorageLive(_4);
unreachable;
}
bb4: {
_0 = const ();
StorageDead(_1);
return;
}
}

View File

@ -45,18 +45,16 @@ fn as_match() {
// CHECK: bb0: {
// CHECK: {{_.*}} = empty()
// CHECK: bb1: {
// CHECK: [[eq:_.*]] = Eq({{.*}}, const 0_isize);
// CHECK: [[eq:_.*]] = Ne({{.*}}, const 1_isize);
// CHECK-NEXT: assume(move [[eq]]);
// CHECK-NEXT: goto -> bb4;
// CHECK-NEXT: goto -> bb2;
// CHECK: bb2: {
// CHECK-NEXT: unreachable;
// CHECK: return;
// CHECK: bb3: {
// CHECK-NEXT: unreachable;
// CHECK: bb4: {
// CHECK: return;
match empty() {
None => {}
Some(_x) => match _x {},
None => {}
}
}

View File

@ -49,7 +49,7 @@ struct Plop {
fn simple() {
// CHECK-LABEL: fn simple(
// CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb2, otherwise: [[unreachable]]];
// CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb1, otherwise: [[unreachable]]];
// CHECK: [[unreachable]]: {
// CHECK-NEXT: unreachable;
match Test1::C {

View File

@ -14,40 +14,40 @@
StorageLive(_2);
_2 = Test1::C;
_3 = discriminant(_2);
- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1];
- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5];
}
bb1: {
unreachable;
}
bb2: {
StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5;
goto -> bb4;
}
bb3: {
bb2: {
StorageLive(_4);
_4 = const "B(Empty)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb5;
goto -> bb4;
}
bb3: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb4: {
_1 = const "A(Empty)";
goto -> bb5;
}
bb5: {
StorageDead(_2);
StorageDead(_1);
_0 = const ();
return;
+ }
+
+ bb5: {
+ unreachable;
}
}

View File

@ -14,40 +14,40 @@
StorageLive(_2);
_2 = Test1::C;
_3 = discriminant(_2);
- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1];
- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5];
}
bb1: {
unreachable;
}
bb2: {
StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5;
goto -> bb4;
}
bb3: {
bb2: {
StorageLive(_4);
_4 = const "B(Empty)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb5;
goto -> bb4;
}
bb3: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb4: {
_1 = const "A(Empty)";
goto -> bb5;
}
bb5: {
StorageDead(_2);
StorageDead(_1);
_0 = const ();
return;
+ }
+
+ bb5: {
+ unreachable;
}
}

View File

@ -1,10 +1,9 @@
// Test precise capture of a multi-variant enum (when remaining variants are
// visibly uninhabited).
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns
//@ edition:2021
//@ run-pass
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]
pub fn main() {

View File

@ -1,4 +1,4 @@
<svg width="740px" height="848px" xmlns="http://www.w3.org/2000/svg">
<svg width="818px" height="848px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -1,8 +1,8 @@
//@ run-pass
#![allow(unreachable_patterns)]
#![allow(dead_code)]
enum Empty { }
enum Empty {}
enum Test1 {
A(u8),
B(Empty),

View File

@ -1,4 +1,5 @@
//@ run-pass
#![allow(unreachable_patterns)]
pub enum Infallible {}

View File

@ -1,4 +1,5 @@
//@ run-pass
#![allow(unreachable_patterns)]
//! Make sure that we read and write enum discriminants correctly for corner cases caused
//! by layout optimizations.

View File

@ -5,5 +5,5 @@ fn foo() -> Result<u32, !> {
}
fn main() {
let Ok(_x) = foo(); //~ ERROR refutable pattern in local binding
let Ok(_x) = &foo(); //~ ERROR refutable pattern in local binding
}

View File

@ -1,16 +1,16 @@
error[E0005]: refutable pattern in local binding
--> $DIR/feature-gate-exhaustive-patterns.rs:8:9
|
LL | let Ok(_x) = foo();
| ^^^^^^ pattern `Err(_)` not covered
LL | let Ok(_x) = &foo();
| ^^^^^^ pattern `&Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Result<u32, !>`
= note: the matched value is of type `&Result<u32, !>`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(_x) = foo() else { todo!() };
| ++++++++++++++++
LL | let Ok(_x) = &foo() else { todo!() };
| ++++++++++++++++
error: aborting due to 1 previous error

View File

@ -2,9 +2,8 @@
#![allow(unused_variables)]
#![allow(unreachable_code)]
#![allow(unreachable_patterns)]
// Test that we can extract a ! through pattern matching then use it as several different types.
#![feature(never_type)]
fn main() {
@ -16,6 +15,6 @@ fn main() {
let w: i32 = y;
let e: String = y;
y
},
}
}
}

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/always-inhabited-union-ref.rs:25:11
--> $DIR/always-inhabited-union-ref.rs:24:11
|
LL | match uninhab_ref() {
| ^^^^^^^^^^^^^
@ -14,13 +14,13 @@ LL + }
|
error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
--> $DIR/always-inhabited-union-ref.rs:29:11
--> $DIR/always-inhabited-union-ref.rs:28:11
|
LL | match uninhab_union() {
| ^^^^^^^^^^^^^^^
|
note: `Foo` defined here
--> $DIR/always-inhabited-union-ref.rs:12:11
--> $DIR/always-inhabited-union-ref.rs:11:11
|
LL | pub union Foo {
| ^^^

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/always-inhabited-union-ref.rs:25:11
--> $DIR/always-inhabited-union-ref.rs:24:11
|
LL | match uninhab_ref() {
| ^^^^^^^^^^^^^
@ -14,13 +14,13 @@ LL + }
|
error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
--> $DIR/always-inhabited-union-ref.rs:29:11
--> $DIR/always-inhabited-union-ref.rs:28:11
|
LL | match uninhab_union() {
| ^^^^^^^^^^^^^^^
|
note: `Foo` defined here
--> $DIR/always-inhabited-union-ref.rs:12:11
--> $DIR/always-inhabited-union-ref.rs:11:11
|
LL | pub union Foo {
| ^^^

View File

@ -1,10 +1,9 @@
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns
// The precise semantics of inhabitedness with respect to unions and references is currently
// undecided. This test file currently checks a conservative choice.
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]
#![allow(dead_code)]
#![allow(unreachable_code)]

View File

@ -38,7 +38,7 @@ LL | _ if false => {}
error[E0005]: refutable pattern in local binding
--> $DIR/empty-match-check-notes.rs:39:9
|
LL | let None = x;
LL | let None = *x;
| ^^^^ pattern `Some(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
@ -47,8 +47,8 @@ LL | let None = x;
= note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let None = x { todo!() };
| ++ +++++++++++
LL | if let None = *x { todo!() };
| ++ +++++++++++
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
--> $DIR/empty-match-check-notes.rs:49:11

View File

@ -38,16 +38,17 @@ LL | _ if false => {}
error[E0005]: refutable pattern in local binding
--> $DIR/empty-match-check-notes.rs:39:9
|
LL | let None = x;
LL | let None = *x;
| ^^^^ pattern `Some(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: pattern `Some(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
= note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let None = x { todo!() };
| ++ +++++++++++
LL | if let None = *x { todo!() };
| ++ +++++++++++
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
--> $DIR/empty-match-check-notes.rs:49:11

View File

@ -35,14 +35,14 @@ fn empty_foreign_enum(x: empty::EmptyForeignEnum) {
}
}
fn empty_foreign_enum_private(x: Option<empty::SecretlyUninhabitedForeignStruct>) {
let None = x;
fn empty_foreign_enum_private(x: &Option<empty::SecretlyUninhabitedForeignStruct>) {
let None = *x;
//~^ ERROR refutable pattern in local binding
//~| NOTE `let` bindings require an "irrefutable pattern"
//~| NOTE for more information, visit
//~| NOTE the matched value is of type
//~| NOTE pattern `Some(_)` not covered
//[exhaustive_patterns]~| NOTE currently uninhabited, but this variant contains private fields
//~| NOTE currently uninhabited, but this variant contains private fields
}
fn main() {

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
--> $DIR/empty-match.rs:46:20
--> $DIR/empty-match.rs:47:20
|
LL | match_no_arms!(0u8);
| ^^^
@ -8,7 +8,7 @@ LL | match_no_arms!(0u8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `i8` is non-empty
--> $DIR/empty-match.rs:47:20
--> $DIR/empty-match.rs:48:20
|
LL | match_no_arms!(0i8);
| ^^^
@ -17,7 +17,7 @@ LL | match_no_arms!(0i8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
--> $DIR/empty-match.rs:48:20
--> $DIR/empty-match.rs:49:20
|
LL | match_no_arms!(0usize);
| ^^^^^^
@ -26,7 +26,7 @@ LL | match_no_arms!(0usize);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `isize` is non-empty
--> $DIR/empty-match.rs:49:20
--> $DIR/empty-match.rs:50:20
|
LL | match_no_arms!(0isize);
| ^^^^^^
@ -35,7 +35,7 @@ LL | match_no_arms!(0isize);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
--> $DIR/empty-match.rs:50:20
--> $DIR/empty-match.rs:51:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
@ -49,7 +49,7 @@ LL | struct NonEmptyStruct1;
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
--> $DIR/empty-match.rs:51:20
--> $DIR/empty-match.rs:52:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
@ -63,7 +63,7 @@ LL | struct NonEmptyStruct2(bool);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
--> $DIR/empty-match.rs:52:20
--> $DIR/empty-match.rs:53:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -77,7 +77,7 @@ LL | union NonEmptyUnion1 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
--> $DIR/empty-match.rs:53:20
--> $DIR/empty-match.rs:54:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -91,7 +91,7 @@ LL | union NonEmptyUnion2 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:54:20
--> $DIR/empty-match.rs:55:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -107,7 +107,7 @@ LL | Foo(bool),
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:55:20
--> $DIR/empty-match.rs:56:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -125,7 +125,7 @@ LL | Bar,
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:56:20
--> $DIR/empty-match.rs:57:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@ -148,8 +148,26 @@ LL | V5,
= note: the matched value is of type `NonEmptyEnum5`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-match.rs:58:20
|
LL | match_no_arms!(array0_of_empty);
| ^^^^^^^^^^^^^^^
|
= note: the matched value is of type `[!; 0]`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `[!; N]` is non-empty
--> $DIR/empty-match.rs:59:20
|
LL | match_no_arms!(arrayN_of_empty);
| ^^^^^^^^^^^^^^^
|
= note: the matched value is of type `[!; N]`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
--> $DIR/empty-match.rs:58:24
--> $DIR/empty-match.rs:61:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `0_u8..=u8::MAX` not covered
@ -163,7 +181,7 @@ LL + 0_u8..=u8::MAX => todo!()
|
error[E0004]: non-exhaustive patterns: `i8::MIN..=i8::MAX` not covered
--> $DIR/empty-match.rs:59:24
--> $DIR/empty-match.rs:62:24
|
LL | match_guarded_arm!(0i8);
| ^^^ pattern `i8::MIN..=i8::MAX` not covered
@ -177,7 +195,7 @@ LL + i8::MIN..=i8::MAX => todo!()
|
error[E0004]: non-exhaustive patterns: `0_usize..` not covered
--> $DIR/empty-match.rs:60:24
--> $DIR/empty-match.rs:63:24
|
LL | match_guarded_arm!(0usize);
| ^^^^^^ pattern `0_usize..` not covered
@ -191,7 +209,7 @@ LL + 0_usize.. => todo!()
|
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/empty-match.rs:61:24
--> $DIR/empty-match.rs:64:24
|
LL | match_guarded_arm!(0isize);
| ^^^^^^ pattern `_` not covered
@ -205,7 +223,7 @@ LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
--> $DIR/empty-match.rs:62:24
--> $DIR/empty-match.rs:65:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@ -224,7 +242,7 @@ LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
--> $DIR/empty-match.rs:63:24
--> $DIR/empty-match.rs:66:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@ -243,7 +261,7 @@ LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
--> $DIR/empty-match.rs:64:24
--> $DIR/empty-match.rs:67:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@ -262,7 +280,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
--> $DIR/empty-match.rs:65:24
--> $DIR/empty-match.rs:68:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@ -273,6 +291,7 @@ note: `NonEmptyUnion2` defined here
LL | union NonEmptyUnion2 {
| ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion2`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
@ -281,7 +300,7 @@ LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:66:24
--> $DIR/empty-match.rs:69:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -302,7 +321,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:67:24
--> $DIR/empty-match.rs:70:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -325,7 +344,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:68:24
--> $DIR/empty-match.rs:71:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@ -353,6 +372,34 @@ LL ~ _ if false => {},
LL + _ => todo!()
|
error: aborting due to 22 previous errors
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-match.rs:72:24
|
LL | match_guarded_arm!(array0_of_empty);
| ^^^^^^^^^^^^^^^ pattern `[]` not covered
|
= note: the matched value is of type `[!; 0]`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ _ if false => {},
LL + [] => todo!()
|
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-match.rs:73:24
|
LL | match_guarded_arm!(arrayN_of_empty);
| ^^^^^^^^^^^^^^^ pattern `[]` not covered
|
= note: the matched value is of type `[!; N]`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ _ if false => {},
LL + [] => todo!()
|
error: aborting due to 26 previous errors
For more information about this error, try `rustc --explain E0004`.

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
--> $DIR/empty-match.rs:46:20
--> $DIR/empty-match.rs:47:20
|
LL | match_no_arms!(0u8);
| ^^^
@ -8,7 +8,7 @@ LL | match_no_arms!(0u8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `i8` is non-empty
--> $DIR/empty-match.rs:47:20
--> $DIR/empty-match.rs:48:20
|
LL | match_no_arms!(0i8);
| ^^^
@ -17,7 +17,7 @@ LL | match_no_arms!(0i8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
--> $DIR/empty-match.rs:48:20
--> $DIR/empty-match.rs:49:20
|
LL | match_no_arms!(0usize);
| ^^^^^^
@ -26,7 +26,7 @@ LL | match_no_arms!(0usize);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `isize` is non-empty
--> $DIR/empty-match.rs:49:20
--> $DIR/empty-match.rs:50:20
|
LL | match_no_arms!(0isize);
| ^^^^^^
@ -35,7 +35,7 @@ LL | match_no_arms!(0isize);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
--> $DIR/empty-match.rs:50:20
--> $DIR/empty-match.rs:51:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
@ -49,7 +49,7 @@ LL | struct NonEmptyStruct1;
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
--> $DIR/empty-match.rs:51:20
--> $DIR/empty-match.rs:52:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
@ -63,7 +63,7 @@ LL | struct NonEmptyStruct2(bool);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
--> $DIR/empty-match.rs:52:20
--> $DIR/empty-match.rs:53:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -77,7 +77,7 @@ LL | union NonEmptyUnion1 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
--> $DIR/empty-match.rs:53:20
--> $DIR/empty-match.rs:54:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -91,7 +91,7 @@ LL | union NonEmptyUnion2 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:54:20
--> $DIR/empty-match.rs:55:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -107,7 +107,7 @@ LL | Foo(bool),
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:55:20
--> $DIR/empty-match.rs:56:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -125,7 +125,7 @@ LL | Bar,
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:56:20
--> $DIR/empty-match.rs:57:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@ -148,8 +148,26 @@ LL | V5,
= note: the matched value is of type `NonEmptyEnum5`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-match.rs:58:20
|
LL | match_no_arms!(array0_of_empty);
| ^^^^^^^^^^^^^^^
|
= note: the matched value is of type `[!; 0]`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `[!; N]` is non-empty
--> $DIR/empty-match.rs:59:20
|
LL | match_no_arms!(arrayN_of_empty);
| ^^^^^^^^^^^^^^^
|
= note: the matched value is of type `[!; N]`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
--> $DIR/empty-match.rs:58:24
--> $DIR/empty-match.rs:61:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `0_u8..=u8::MAX` not covered
@ -163,7 +181,7 @@ LL + 0_u8..=u8::MAX => todo!()
|
error[E0004]: non-exhaustive patterns: `i8::MIN..=i8::MAX` not covered
--> $DIR/empty-match.rs:59:24
--> $DIR/empty-match.rs:62:24
|
LL | match_guarded_arm!(0i8);
| ^^^ pattern `i8::MIN..=i8::MAX` not covered
@ -177,7 +195,7 @@ LL + i8::MIN..=i8::MAX => todo!()
|
error[E0004]: non-exhaustive patterns: `0_usize..` not covered
--> $DIR/empty-match.rs:60:24
--> $DIR/empty-match.rs:63:24
|
LL | match_guarded_arm!(0usize);
| ^^^^^^ pattern `0_usize..` not covered
@ -191,7 +209,7 @@ LL + 0_usize.. => todo!()
|
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/empty-match.rs:61:24
--> $DIR/empty-match.rs:64:24
|
LL | match_guarded_arm!(0isize);
| ^^^^^^ pattern `_` not covered
@ -205,7 +223,7 @@ LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
--> $DIR/empty-match.rs:62:24
--> $DIR/empty-match.rs:65:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@ -224,7 +242,7 @@ LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
--> $DIR/empty-match.rs:63:24
--> $DIR/empty-match.rs:66:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@ -243,7 +261,7 @@ LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
--> $DIR/empty-match.rs:64:24
--> $DIR/empty-match.rs:67:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@ -262,7 +280,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
--> $DIR/empty-match.rs:65:24
--> $DIR/empty-match.rs:68:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@ -273,6 +291,7 @@ note: `NonEmptyUnion2` defined here
LL | union NonEmptyUnion2 {
| ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion2`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
@ -281,7 +300,7 @@ LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:66:24
--> $DIR/empty-match.rs:69:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -302,7 +321,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:67:24
--> $DIR/empty-match.rs:70:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -325,7 +344,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:68:24
--> $DIR/empty-match.rs:71:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@ -353,6 +372,34 @@ LL ~ _ if false => {},
LL + _ => todo!()
|
error: aborting due to 22 previous errors
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-match.rs:72:24
|
LL | match_guarded_arm!(array0_of_empty);
| ^^^^^^^^^^^^^^^ pattern `[]` not covered
|
= note: the matched value is of type `[!; 0]`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ _ if false => {},
LL + [] => todo!()
|
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-match.rs:73:24
|
LL | match_guarded_arm!(arrayN_of_empty);
| ^^^^^^^^^^^^^^^ pattern `[]` not covered
|
= note: the matched value is of type `[!; N]`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ _ if false => {},
LL + [] => todo!()
|
error: aborting due to 26 previous errors
For more information about this error, try `rustc --explain E0004`.

View File

@ -5,7 +5,7 @@
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![deny(unreachable_patterns)]
fn nonempty() {
fn nonempty<const N: usize>(arrayN_of_empty: [!; N]) {
macro_rules! match_no_arms {
($e:expr) => {
match $e {}
@ -42,6 +42,7 @@ fn nonempty() {
V4,
V5,
}
let array0_of_empty: [!; 0] = [];
match_no_arms!(0u8); //~ ERROR type `u8` is non-empty
match_no_arms!(0i8); //~ ERROR type `i8` is non-empty
@ -54,6 +55,8 @@ fn nonempty() {
match_no_arms!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered
match_no_arms!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
match_no_arms!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
match_no_arms!(array0_of_empty); //~ ERROR type `[!; 0]` is non-empty
match_no_arms!(arrayN_of_empty); //~ ERROR type `[!; N]` is non-empty
match_guarded_arm!(0u8); //~ ERROR `0_u8..=u8::MAX` not covered
match_guarded_arm!(0i8); //~ ERROR `i8::MIN..=i8::MAX` not covered
@ -66,6 +69,8 @@ fn nonempty() {
match_guarded_arm!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered
match_guarded_arm!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
match_guarded_arm!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
match_guarded_arm!(array0_of_empty); //~ ERROR `[]` not covered
match_guarded_arm!(arrayN_of_empty); //~ ERROR `[]` not covered
}
fn main() {}

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/empty-types.rs:51:9
--> $DIR/empty-types.rs:49:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
note: the lint level is defined here
--> $DIR/empty-types.rs:17:9
--> $DIR/empty-types.rs:15:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/empty-types.rs:54:9
--> $DIR/empty-types.rs:52:9
|
LL | _x => {}
| ^^
@ -20,7 +20,7 @@ LL | _x => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/empty-types.rs:58:11
--> $DIR/empty-types.rs:56:11
|
LL | match ref_never {}
| ^^^^^^^^^
@ -35,7 +35,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:73:9
--> $DIR/empty-types.rs:70:9
|
LL | (_, _) => {}
| ^^^^^^
@ -43,7 +43,7 @@ LL | (_, _) => {}
= note: this pattern matches no values because `(u32, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:80:9
--> $DIR/empty-types.rs:76:9
|
LL | _ => {}
| ^
@ -51,7 +51,7 @@ LL | _ => {}
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:83:9
--> $DIR/empty-types.rs:79:9
|
LL | (_, _) => {}
| ^^^^^^
@ -59,7 +59,7 @@ LL | (_, _) => {}
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:87:9
--> $DIR/empty-types.rs:83:9
|
LL | _ => {}
| ^
@ -67,7 +67,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
--> $DIR/empty-types.rs:91:11
--> $DIR/empty-types.rs:87:11
|
LL | match res_u32_never {}
| ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
@ -86,7 +86,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:99:9
--> $DIR/empty-types.rs:94:9
|
LL | Err(_) => {}
| ^^^^^^
@ -94,7 +94,7 @@ LL | Err(_) => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:104:9
--> $DIR/empty-types.rs:99:9
|
LL | Err(_) => {}
| ^^^^^^
@ -102,7 +102,7 @@ LL | Err(_) => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
--> $DIR/empty-types.rs:101:11
--> $DIR/empty-types.rs:96:11
|
LL | match res_u32_never {
| ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
@ -120,7 +120,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!()
|
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:108:9
--> $DIR/empty-types.rs:102:9
|
LL | let Ok(_x) = res_u32_never.as_ref();
| ^^^^^^ pattern `Err(_)` not covered
@ -133,6 +133,30 @@ help: you might want to use `let else` to handle the variant that isn't matched
LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
| ++++++++++++++++
error: unreachable pattern
--> $DIR/empty-types.rs:112:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:115:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:118:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:119:9
|
@ -141,48 +165,24 @@ LL | _ => {}
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:122:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:123:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:126:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:127:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:130:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:131:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:140:13
--> $DIR/empty-types.rs:132:13
|
LL | _ => {}
| ^
@ -190,7 +190,7 @@ LL | _ => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
--> $DIR/empty-types.rs:135:13
|
LL | _ if false => {}
| ^
@ -198,7 +198,7 @@ LL | _ if false => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:152:13
--> $DIR/empty-types.rs:143:13
|
LL | Some(_) => {}
| ^^^^^^^
@ -206,7 +206,7 @@ LL | Some(_) => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:156:13
--> $DIR/empty-types.rs:147:13
|
LL | None => {}
| ---- matches all the values already
@ -214,7 +214,7 @@ LL | _ => {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/empty-types.rs:208:13
--> $DIR/empty-types.rs:199:13
|
LL | _ => {}
| ^
@ -222,7 +222,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:213:13
--> $DIR/empty-types.rs:204:13
|
LL | _ => {}
| ^
@ -230,7 +230,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:218:13
--> $DIR/empty-types.rs:209:13
|
LL | _ => {}
| ^
@ -238,7 +238,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:223:13
--> $DIR/empty-types.rs:214:13
|
LL | _ => {}
| ^
@ -246,7 +246,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:229:13
--> $DIR/empty-types.rs:220:13
|
LL | _ => {}
| ^
@ -254,7 +254,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:288:9
--> $DIR/empty-types.rs:279:9
|
LL | _ => {}
| ^
@ -262,7 +262,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:291:9
--> $DIR/empty-types.rs:282:9
|
LL | (_, _) => {}
| ^^^^^^
@ -270,7 +270,7 @@ LL | (_, _) => {}
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:294:9
--> $DIR/empty-types.rs:285:9
|
LL | Ok(_) => {}
| ^^^^^
@ -278,7 +278,7 @@ LL | Ok(_) => {}
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:295:9
--> $DIR/empty-types.rs:286:9
|
LL | Err(_) => {}
| ^^^^^^
@ -286,7 +286,7 @@ LL | Err(_) => {}
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
--> $DIR/empty-types.rs:327:11
--> $DIR/empty-types.rs:318:11
|
LL | match slice_never {}
| ^^^^^^^^^^^
@ -300,7 +300,7 @@ LL + }
|
error[E0004]: non-exhaustive patterns: `&[]` not covered
--> $DIR/empty-types.rs:338:11
--> $DIR/empty-types.rs:329:11
|
LL | match slice_never {
| ^^^^^^^^^^^ pattern `&[]` not covered
@ -313,7 +313,7 @@ LL + &[] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` not covered
--> $DIR/empty-types.rs:352:11
--> $DIR/empty-types.rs:343:11
|
LL | match slice_never {
| ^^^^^^^^^^^ pattern `&[]` not covered
@ -327,7 +327,7 @@ LL + &[] => todo!()
|
error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
--> $DIR/empty-types.rs:359:11
--> $DIR/empty-types.rs:350:11
|
LL | match *slice_never {}
| ^^^^^^^^^^^^
@ -341,7 +341,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:369:9
--> $DIR/empty-types.rs:359:9
|
LL | _ => {}
| ^
@ -349,7 +349,7 @@ LL | _ => {}
= note: this pattern matches no values because `[!; 3]` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:372:9
--> $DIR/empty-types.rs:362:9
|
LL | [_, _, _] => {}
| ^^^^^^^^^
@ -357,7 +357,7 @@ LL | [_, _, _] => {}
= note: this pattern matches no values because `[!; 3]` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:375:9
--> $DIR/empty-types.rs:365:9
|
LL | [_, ..] => {}
| ^^^^^^^
@ -365,7 +365,7 @@ LL | [_, ..] => {}
= note: this pattern matches no values because `[!; 3]` is uninhabited
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-types.rs:389:11
--> $DIR/empty-types.rs:379:11
|
LL | match array_0_never {}
| ^^^^^^^^^^^^^
@ -379,7 +379,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:396:9
--> $DIR/empty-types.rs:386:9
|
LL | [] => {}
| -- matches all the values already
@ -387,7 +387,7 @@ LL | _ => {}
| ^ unreachable pattern
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-types.rs:398:11
--> $DIR/empty-types.rs:388:11
|
LL | match array_0_never {
| ^^^^^^^^^^^^^ pattern `[]` not covered
@ -401,7 +401,7 @@ LL + [] => todo!()
|
error: unreachable pattern
--> $DIR/empty-types.rs:417:9
--> $DIR/empty-types.rs:407:9
|
LL | Some(_) => {}
| ^^^^^^^
@ -409,7 +409,7 @@ LL | Some(_) => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:422:9
--> $DIR/empty-types.rs:412:9
|
LL | Some(_a) => {}
| ^^^^^^^^
@ -417,7 +417,7 @@ LL | Some(_a) => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:427:9
--> $DIR/empty-types.rs:417:9
|
LL | None => {}
| ---- matches all the values already
@ -426,7 +426,7 @@ LL | _ => {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/empty-types.rs:432:9
--> $DIR/empty-types.rs:422:9
|
LL | None => {}
| ---- matches all the values already
@ -435,7 +435,7 @@ LL | _a => {}
| ^^ unreachable pattern
error: unreachable pattern
--> $DIR/empty-types.rs:604:9
--> $DIR/empty-types.rs:594:9
|
LL | _ => {}
| ^
@ -443,7 +443,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:607:9
--> $DIR/empty-types.rs:597:9
|
LL | _x => {}
| ^^
@ -451,7 +451,7 @@ LL | _x => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:610:9
--> $DIR/empty-types.rs:600:9
|
LL | _ if false => {}
| ^
@ -459,7 +459,7 @@ LL | _ if false => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:613:9
--> $DIR/empty-types.rs:603:9
|
LL | _x if false => {}
| ^^

View File

@ -1,5 +1,5 @@
warning: the feature `never_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/empty-types.rs:14:33
--> $DIR/empty-types.rs:12:33
|
LL | #![cfg_attr(never_pats, feature(never_patterns))]
| ^^^^^^^^^^^^^^
@ -8,20 +8,20 @@ LL | #![cfg_attr(never_pats, feature(never_patterns))]
= note: `#[warn(incomplete_features)]` on by default
error: unreachable pattern
--> $DIR/empty-types.rs:51:9
--> $DIR/empty-types.rs:49:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
note: the lint level is defined here
--> $DIR/empty-types.rs:17:9
--> $DIR/empty-types.rs:15:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/empty-types.rs:54:9
--> $DIR/empty-types.rs:52:9
|
LL | _x => {}
| ^^
@ -29,7 +29,7 @@ LL | _x => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/empty-types.rs:58:11
--> $DIR/empty-types.rs:56:11
|
LL | match ref_never {}
| ^^^^^^^^^
@ -43,69 +43,43 @@ LL + _ => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
--> $DIR/empty-types.rs:70:11
error: unreachable pattern
--> $DIR/empty-types.rs:70:9
|
LL | match tuple_half_never {}
| ^^^^^^^^^^^^^^^^
|
= note: the matched value is of type `(u32, !)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match tuple_half_never {
LL + _ => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
--> $DIR/empty-types.rs:77:11
|
LL | match tuple_never {}
| ^^^^^^^^^^^
|
= note: the matched value is of type `(!, !)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match tuple_never {
LL + _ => todo!(),
LL + }
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(u32, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:87:9
--> $DIR/empty-types.rs:76:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:79:9
|
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:83:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(!)` not covered
--> $DIR/empty-types.rs:91:11
error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
--> $DIR/empty-types.rs:87:11
|
LL | match res_u32_never {}
| ^^^^^^^^^^^^^ patterns `Ok(_)` and `Err(!)` not covered
|
note: `Result<u32, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<u32, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ match res_u32_never {
LL + Ok(_) | Err(!) => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: `Err(!)` not covered
--> $DIR/empty-types.rs:93:11
|
LL | match res_u32_never {
| ^^^^^^^^^^^^^ pattern `Err(!)` not covered
| ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
|
note: `Result<u32, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
@ -115,12 +89,29 @@ note: `Result<u32, !>` defined here
= note: the matched value is of type `Result<u32, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(_) => {},
LL + Err(!)
LL ~ match res_u32_never {
LL + Ok(_) => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:94:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:99:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
--> $DIR/empty-types.rs:101:11
--> $DIR/empty-types.rs:96:11
|
LL | match res_u32_never {
| ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
@ -138,21 +129,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!()
|
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:106:9
|
LL | let Ok(_x) = res_u32_never;
| ^^^^^^ pattern `Err(!)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Result<u32, !>`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(_x) = res_u32_never else { todo!() };
| ++++++++++++++++
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:108:9
--> $DIR/empty-types.rs:102:9
|
LL | let Ok(_x) = res_u32_never.as_ref();
| ^^^^^^ pattern `Err(_)` not covered
@ -166,7 +143,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
| ++++++++++++++++
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:112:9
--> $DIR/empty-types.rs:106:9
|
LL | let Ok(_x) = &res_u32_never;
| ^^^^^^ pattern `&Err(!)` not covered
@ -179,47 +156,56 @@ help: you might want to use `let else` to handle the variant that isn't matched
LL | let Ok(_x) = &res_u32_never else { todo!() };
| ++++++++++++++++
error[E0004]: non-exhaustive patterns: `Ok(!)` and `Err(!)` not covered
--> $DIR/empty-types.rs:116:11
error: unreachable pattern
--> $DIR/empty-types.rs:112:9
|
LL | match result_never {}
| ^^^^^^^^^^^^ patterns `Ok(!)` and `Err(!)` not covered
LL | _ => {}
| ^
|
note: `Result<!, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ match result_never {
LL + Ok(!) | Err(!),
LL + }
|
error[E0004]: non-exhaustive patterns: `Err(!)` not covered
--> $DIR/empty-types.rs:121:11
|
LL | match result_never {
| ^^^^^^^^^^^^ pattern `Err(!)` not covered
|
note: `Result<!, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | Ok(_) => {}, Err(!)
| ++++++++
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:140:13
--> $DIR/empty-types.rs:115:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:118:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:119:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:122:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:123:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:132:13
|
LL | _ => {}
| ^
@ -227,33 +213,31 @@ LL | _ => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
--> $DIR/empty-types.rs:135:13
|
LL | _ if false => {}
| ^
|
= note: this pattern matches no values because `Void` is uninhabited
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
--> $DIR/empty-types.rs:146:15
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
|
LL | match opt_void {
| ^^^^^^^^ pattern `Some(!)` not covered
LL | Some(_) => {}
| ^^^^^^^
|
note: `Option<Void>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
::: $SRC_DIR/core/src/option.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Option<Void>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
LL + Some(!)
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:147:13
|
LL | None => {}
| ---- matches all the values already
LL | _ => {}
| ^ unreachable pattern
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
--> $DIR/empty-types.rs:165:15
--> $DIR/empty-types.rs:156:15
|
LL | match *ref_opt_void {
| ^^^^^^^^^^^^^ pattern `Some(!)` not covered
@ -264,6 +248,7 @@ note: `Option<Void>` defined here
|
= note: not covered
= note: the matched value is of type `Option<Void>`
= note: `Void` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
@ -271,7 +256,7 @@ LL + Some(!)
|
error: unreachable pattern
--> $DIR/empty-types.rs:208:13
--> $DIR/empty-types.rs:199:13
|
LL | _ => {}
| ^
@ -279,7 +264,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:213:13
--> $DIR/empty-types.rs:204:13
|
LL | _ => {}
| ^
@ -287,7 +272,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:218:13
--> $DIR/empty-types.rs:209:13
|
LL | _ => {}
| ^
@ -295,7 +280,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:223:13
--> $DIR/empty-types.rs:214:13
|
LL | _ => {}
| ^
@ -303,7 +288,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:229:13
--> $DIR/empty-types.rs:220:13
|
LL | _ => {}
| ^
@ -311,15 +296,39 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:288:9
--> $DIR/empty-types.rs:279:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:282:9
|
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:285:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:286:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
--> $DIR/empty-types.rs:316:11
--> $DIR/empty-types.rs:307:11
|
LL | match *x {}
| ^^
@ -333,7 +342,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
--> $DIR/empty-types.rs:318:11
--> $DIR/empty-types.rs:309:11
|
LL | match *x {}
| ^^
@ -347,7 +356,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: `Ok(!)` and `Err(!)` not covered
--> $DIR/empty-types.rs:320:11
--> $DIR/empty-types.rs:311:11
|
LL | match *x {}
| ^^ patterns `Ok(!)` and `Err(!)` not covered
@ -369,7 +378,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
--> $DIR/empty-types.rs:322:11
--> $DIR/empty-types.rs:313:11
|
LL | match *x {}
| ^^
@ -383,7 +392,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
--> $DIR/empty-types.rs:327:11
--> $DIR/empty-types.rs:318:11
|
LL | match slice_never {}
| ^^^^^^^^^^^
@ -397,12 +406,13 @@ LL + }
|
error[E0004]: non-exhaustive patterns: `&[!, ..]` not covered
--> $DIR/empty-types.rs:329:11
--> $DIR/empty-types.rs:320:11
|
LL | match slice_never {
| ^^^^^^^^^^^ pattern `&[!, ..]` not covered
|
= note: the matched value is of type `&[!]`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ [] => {},
@ -410,7 +420,7 @@ LL + &[!, ..]
|
error[E0004]: non-exhaustive patterns: `&[]`, `&[!]` and `&[!, !]` not covered
--> $DIR/empty-types.rs:338:11
--> $DIR/empty-types.rs:329:11
|
LL | match slice_never {
| ^^^^^^^^^^^ patterns `&[]`, `&[!]` and `&[!, !]` not covered
@ -423,7 +433,7 @@ LL + &[] | &[!] | &[!, !] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[!, ..]` not covered
--> $DIR/empty-types.rs:352:11
--> $DIR/empty-types.rs:343:11
|
LL | match slice_never {
| ^^^^^^^^^^^ patterns `&[]` and `&[!, ..]` not covered
@ -437,7 +447,7 @@ LL + &[] | &[!, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
--> $DIR/empty-types.rs:359:11
--> $DIR/empty-types.rs:350:11
|
LL | match *slice_never {}
| ^^^^^^^^^^^^
@ -450,22 +460,32 @@ LL + _ => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
--> $DIR/empty-types.rs:366:11
error: unreachable pattern
--> $DIR/empty-types.rs:359:9
|
LL | match array_3_never {}
| ^^^^^^^^^^^^^
LL | _ => {}
| ^
|
= note: the matched value is of type `[!; 3]`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
= note: this pattern matches no values because `[!; 3]` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:362:9
|
LL ~ match array_3_never {
LL + _ => todo!(),
LL + }
LL | [_, _, _] => {}
| ^^^^^^^^^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:365:9
|
LL | [_, ..] => {}
| ^^^^^^^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-types.rs:389:11
--> $DIR/empty-types.rs:379:11
|
LL | match array_0_never {}
| ^^^^^^^^^^^^^
@ -479,7 +499,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:396:9
--> $DIR/empty-types.rs:386:9
|
LL | [] => {}
| -- matches all the values already
@ -487,7 +507,7 @@ LL | _ => {}
| ^ unreachable pattern
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-types.rs:398:11
--> $DIR/empty-types.rs:388:11
|
LL | match array_0_never {
| ^^^^^^^^^^^^^ pattern `[]` not covered
@ -500,8 +520,42 @@ LL ~ [..] if false => {},
LL + [] => todo!()
|
error: unreachable pattern
--> $DIR/empty-types.rs:407:9
|
LL | Some(_) => {}
| ^^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:412:9
|
LL | Some(_a) => {}
| ^^^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:417:9
|
LL | None => {}
| ---- matches all the values already
LL | // !useful, !reachable
LL | _ => {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/empty-types.rs:422:9
|
LL | None => {}
| ---- matches all the values already
LL | // !useful, !reachable
LL | _a => {}
| ^^ unreachable pattern
error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
--> $DIR/empty-types.rs:452:11
--> $DIR/empty-types.rs:442:11
|
LL | match ref_opt_never {
| ^^^^^^^^^^^^^ pattern `&Some(!)` not covered
@ -512,6 +566,7 @@ note: `Option<!>` defined here
|
= note: not covered
= note: the matched value is of type `&Option<!>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ &None => {},
@ -519,7 +574,7 @@ LL + &Some(!)
|
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
--> $DIR/empty-types.rs:493:11
--> $DIR/empty-types.rs:483:11
|
LL | match *ref_opt_never {
| ^^^^^^^^^^^^^^ pattern `Some(!)` not covered
@ -530,6 +585,7 @@ note: `Option<!>` defined here
|
= note: not covered
= note: the matched value is of type `Option<!>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
@ -537,7 +593,7 @@ LL + Some(!)
|
error[E0004]: non-exhaustive patterns: `Err(!)` not covered
--> $DIR/empty-types.rs:541:11
--> $DIR/empty-types.rs:531:11
|
LL | match *ref_res_never {
| ^^^^^^^^^^^^^^ pattern `Err(!)` not covered
@ -548,6 +604,7 @@ note: `Result<!, !>` defined here
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(_) => {},
@ -555,7 +612,7 @@ LL + Err(!)
|
error[E0004]: non-exhaustive patterns: `Err(!)` not covered
--> $DIR/empty-types.rs:552:11
--> $DIR/empty-types.rs:542:11
|
LL | match *ref_res_never {
| ^^^^^^^^^^^^^^ pattern `Err(!)` not covered
@ -566,6 +623,7 @@ note: `Result<!, !>` defined here
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(_a) => {},
@ -573,7 +631,7 @@ LL + Err(!)
|
error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
--> $DIR/empty-types.rs:571:11
--> $DIR/empty-types.rs:561:11
|
LL | match *ref_tuple_half_never {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -587,7 +645,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:604:9
--> $DIR/empty-types.rs:594:9
|
LL | _ => {}
| ^
@ -595,7 +653,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:607:9
--> $DIR/empty-types.rs:597:9
|
LL | _x => {}
| ^^
@ -603,7 +661,7 @@ LL | _x => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:610:9
--> $DIR/empty-types.rs:600:9
|
LL | _ if false => {}
| ^
@ -611,7 +669,7 @@ LL | _ if false => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:613:9
--> $DIR/empty-types.rs:603:9
|
LL | _x if false => {}
| ^^
@ -619,12 +677,13 @@ LL | _x if false => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `&!` not covered
--> $DIR/empty-types.rs:638:11
--> $DIR/empty-types.rs:628:11
|
LL | match ref_never {
| ^^^^^^^^^ pattern `&!` not covered
|
= note: the matched value is of type `&!`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
= note: references are always considered inhabited
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@ -634,7 +693,7 @@ LL + &!
|
error[E0004]: non-exhaustive patterns: `Ok(!)` not covered
--> $DIR/empty-types.rs:654:11
--> $DIR/empty-types.rs:644:11
|
LL | match *ref_result_never {
| ^^^^^^^^^^^^^^^^^ pattern `Ok(!)` not covered
@ -645,6 +704,7 @@ note: `Result<!, !>` defined here
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Err(_) => {},
@ -652,7 +712,7 @@ LL + Ok(!)
|
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
--> $DIR/empty-types.rs:674:11
--> $DIR/empty-types.rs:664:11
|
LL | match *x {
| ^^ pattern `Some(!)` not covered
@ -663,13 +723,14 @@ note: `Option<Result<!, !>>` defined here
|
= note: not covered
= note: the matched value is of type `Option<Result<!, !>>`
= note: `Result<!, !>` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
LL + Some(!)
|
error: aborting due to 49 previous errors; 1 warning emitted
error: aborting due to 64 previous errors; 1 warning emitted
Some errors have detailed explanations: E0004, E0005.
For more information about an error, try `rustc --explain E0004`.

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/empty-types.rs:51:9
--> $DIR/empty-types.rs:49:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
note: the lint level is defined here
--> $DIR/empty-types.rs:17:9
--> $DIR/empty-types.rs:15:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/empty-types.rs:54:9
--> $DIR/empty-types.rs:52:9
|
LL | _x => {}
| ^^
@ -20,7 +20,7 @@ LL | _x => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/empty-types.rs:58:11
--> $DIR/empty-types.rs:56:11
|
LL | match ref_never {}
| ^^^^^^^^^
@ -34,69 +34,43 @@ LL + _ => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
--> $DIR/empty-types.rs:70:11
error: unreachable pattern
--> $DIR/empty-types.rs:70:9
|
LL | match tuple_half_never {}
| ^^^^^^^^^^^^^^^^
|
= note: the matched value is of type `(u32, !)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match tuple_half_never {
LL + _ => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
--> $DIR/empty-types.rs:77:11
|
LL | match tuple_never {}
| ^^^^^^^^^^^
|
= note: the matched value is of type `(!, !)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match tuple_never {
LL + _ => todo!(),
LL + }
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(u32, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:87:9
--> $DIR/empty-types.rs:76:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:79:9
|
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:83:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
--> $DIR/empty-types.rs:91:11
error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
--> $DIR/empty-types.rs:87:11
|
LL | match res_u32_never {}
| ^^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered
|
note: `Result<u32, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<u32, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ match res_u32_never {
LL + Ok(_) | Err(_) => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
--> $DIR/empty-types.rs:93:11
|
LL | match res_u32_never {
| ^^^^^^^^^^^^^ pattern `Err(_)` not covered
| ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
|
note: `Result<u32, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
@ -106,12 +80,29 @@ note: `Result<u32, !>` defined here
= note: the matched value is of type `Result<u32, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(_) => {},
LL + Err(_) => todo!()
LL ~ match res_u32_never {
LL + Ok(_) => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:94:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:99:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
--> $DIR/empty-types.rs:101:11
--> $DIR/empty-types.rs:96:11
|
LL | match res_u32_never {
| ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
@ -129,21 +120,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!()
|
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:106:9
|
LL | let Ok(_x) = res_u32_never;
| ^^^^^^ pattern `Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Result<u32, !>`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(_x) = res_u32_never else { todo!() };
| ++++++++++++++++
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:108:9
--> $DIR/empty-types.rs:102:9
|
LL | let Ok(_x) = res_u32_never.as_ref();
| ^^^^^^ pattern `Err(_)` not covered
@ -157,7 +134,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
| ++++++++++++++++
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:112:9
--> $DIR/empty-types.rs:106:9
|
LL | let Ok(_x) = &res_u32_never;
| ^^^^^^ pattern `&Err(_)` not covered
@ -170,47 +147,56 @@ help: you might want to use `let else` to handle the variant that isn't matched
LL | let Ok(_x) = &res_u32_never else { todo!() };
| ++++++++++++++++
error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
--> $DIR/empty-types.rs:116:11
error: unreachable pattern
--> $DIR/empty-types.rs:112:9
|
LL | match result_never {}
| ^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered
LL | _ => {}
| ^
|
note: `Result<!, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ match result_never {
LL + Ok(_) | Err(_) => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
--> $DIR/empty-types.rs:121:11
|
LL | match result_never {
| ^^^^^^^^^^^^ pattern `Err(_)` not covered
|
note: `Result<!, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | Ok(_) => {}, Err(_) => todo!()
| +++++++++++++++++++
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:140:13
--> $DIR/empty-types.rs:115:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:118:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:119:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:122:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:123:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:132:13
|
LL | _ => {}
| ^
@ -218,33 +204,31 @@ LL | _ => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
--> $DIR/empty-types.rs:135:13
|
LL | _ if false => {}
| ^
|
= note: this pattern matches no values because `Void` is uninhabited
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> $DIR/empty-types.rs:146:15
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
|
LL | match opt_void {
| ^^^^^^^^ pattern `Some(_)` not covered
LL | Some(_) => {}
| ^^^^^^^
|
note: `Option<Void>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
::: $SRC_DIR/core/src/option.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Option<Void>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
LL + Some(_) => todo!()
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:147:13
|
LL | None => {}
| ---- matches all the values already
LL | _ => {}
| ^ unreachable pattern
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> $DIR/empty-types.rs:165:15
--> $DIR/empty-types.rs:156:15
|
LL | match *ref_opt_void {
| ^^^^^^^^^^^^^ pattern `Some(_)` not covered
@ -255,6 +239,7 @@ note: `Option<Void>` defined here
|
= note: not covered
= note: the matched value is of type `Option<Void>`
= note: `Void` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
@ -262,7 +247,7 @@ LL + Some(_) => todo!()
|
error: unreachable pattern
--> $DIR/empty-types.rs:208:13
--> $DIR/empty-types.rs:199:13
|
LL | _ => {}
| ^
@ -270,7 +255,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:213:13
--> $DIR/empty-types.rs:204:13
|
LL | _ => {}
| ^
@ -278,7 +263,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:218:13
--> $DIR/empty-types.rs:209:13
|
LL | _ => {}
| ^
@ -286,7 +271,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:223:13
--> $DIR/empty-types.rs:214:13
|
LL | _ => {}
| ^
@ -294,7 +279,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:229:13
--> $DIR/empty-types.rs:220:13
|
LL | _ => {}
| ^
@ -302,15 +287,39 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:288:9
--> $DIR/empty-types.rs:279:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:282:9
|
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(!, !)` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:285:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:286:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited
error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
--> $DIR/empty-types.rs:316:11
--> $DIR/empty-types.rs:307:11
|
LL | match *x {}
| ^^
@ -324,7 +333,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
--> $DIR/empty-types.rs:318:11
--> $DIR/empty-types.rs:309:11
|
LL | match *x {}
| ^^
@ -338,7 +347,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
--> $DIR/empty-types.rs:320:11
--> $DIR/empty-types.rs:311:11
|
LL | match *x {}
| ^^ patterns `Ok(_)` and `Err(_)` not covered
@ -360,7 +369,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
--> $DIR/empty-types.rs:322:11
--> $DIR/empty-types.rs:313:11
|
LL | match *x {}
| ^^
@ -374,7 +383,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
--> $DIR/empty-types.rs:327:11
--> $DIR/empty-types.rs:318:11
|
LL | match slice_never {}
| ^^^^^^^^^^^
@ -388,12 +397,13 @@ LL + }
|
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
--> $DIR/empty-types.rs:329:11
--> $DIR/empty-types.rs:320:11
|
LL | match slice_never {
| ^^^^^^^^^^^ pattern `&[_, ..]` not covered
|
= note: the matched value is of type `&[!]`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ [] => {},
@ -401,7 +411,7 @@ LL + &[_, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered
--> $DIR/empty-types.rs:338:11
--> $DIR/empty-types.rs:329:11
|
LL | match slice_never {
| ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered
@ -414,7 +424,7 @@ LL + &[] | &[_] | &[_, _] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered
--> $DIR/empty-types.rs:352:11
--> $DIR/empty-types.rs:343:11
|
LL | match slice_never {
| ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered
@ -428,7 +438,7 @@ LL + &[] | &[_, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
--> $DIR/empty-types.rs:359:11
--> $DIR/empty-types.rs:350:11
|
LL | match *slice_never {}
| ^^^^^^^^^^^^
@ -441,22 +451,32 @@ LL + _ => todo!(),
LL + }
|
error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
--> $DIR/empty-types.rs:366:11
error: unreachable pattern
--> $DIR/empty-types.rs:359:9
|
LL | match array_3_never {}
| ^^^^^^^^^^^^^
LL | _ => {}
| ^
|
= note: the matched value is of type `[!; 3]`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
= note: this pattern matches no values because `[!; 3]` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:362:9
|
LL ~ match array_3_never {
LL + _ => todo!(),
LL + }
LL | [_, _, _] => {}
| ^^^^^^^^^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:365:9
|
LL | [_, ..] => {}
| ^^^^^^^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-types.rs:389:11
--> $DIR/empty-types.rs:379:11
|
LL | match array_0_never {}
| ^^^^^^^^^^^^^
@ -470,7 +490,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:396:9
--> $DIR/empty-types.rs:386:9
|
LL | [] => {}
| -- matches all the values already
@ -478,7 +498,7 @@ LL | _ => {}
| ^ unreachable pattern
error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-types.rs:398:11
--> $DIR/empty-types.rs:388:11
|
LL | match array_0_never {
| ^^^^^^^^^^^^^ pattern `[]` not covered
@ -491,8 +511,42 @@ LL ~ [..] if false => {},
LL + [] => todo!()
|
error: unreachable pattern
--> $DIR/empty-types.rs:407:9
|
LL | Some(_) => {}
| ^^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:412:9
|
LL | Some(_a) => {}
| ^^^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:417:9
|
LL | None => {}
| ---- matches all the values already
LL | // !useful, !reachable
LL | _ => {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/empty-types.rs:422:9
|
LL | None => {}
| ---- matches all the values already
LL | // !useful, !reachable
LL | _a => {}
| ^^ unreachable pattern
error[E0004]: non-exhaustive patterns: `&Some(_)` not covered
--> $DIR/empty-types.rs:452:11
--> $DIR/empty-types.rs:442:11
|
LL | match ref_opt_never {
| ^^^^^^^^^^^^^ pattern `&Some(_)` not covered
@ -503,6 +557,7 @@ note: `Option<!>` defined here
|
= note: not covered
= note: the matched value is of type `&Option<!>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ &None => {},
@ -510,7 +565,7 @@ LL + &Some(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> $DIR/empty-types.rs:493:11
--> $DIR/empty-types.rs:483:11
|
LL | match *ref_opt_never {
| ^^^^^^^^^^^^^^ pattern `Some(_)` not covered
@ -521,6 +576,7 @@ note: `Option<!>` defined here
|
= note: not covered
= note: the matched value is of type `Option<!>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
@ -528,7 +584,7 @@ LL + Some(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
--> $DIR/empty-types.rs:541:11
--> $DIR/empty-types.rs:531:11
|
LL | match *ref_res_never {
| ^^^^^^^^^^^^^^ pattern `Err(_)` not covered
@ -539,6 +595,7 @@ note: `Result<!, !>` defined here
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(_) => {},
@ -546,7 +603,7 @@ LL + Err(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
--> $DIR/empty-types.rs:552:11
--> $DIR/empty-types.rs:542:11
|
LL | match *ref_res_never {
| ^^^^^^^^^^^^^^ pattern `Err(_)` not covered
@ -557,6 +614,7 @@ note: `Result<!, !>` defined here
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(_a) => {},
@ -564,7 +622,7 @@ LL + Err(_) => todo!()
|
error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
--> $DIR/empty-types.rs:571:11
--> $DIR/empty-types.rs:561:11
|
LL | match *ref_tuple_half_never {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -578,7 +636,7 @@ LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:604:9
--> $DIR/empty-types.rs:594:9
|
LL | _ => {}
| ^
@ -586,7 +644,7 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:607:9
--> $DIR/empty-types.rs:597:9
|
LL | _x => {}
| ^^
@ -594,7 +652,7 @@ LL | _x => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:610:9
--> $DIR/empty-types.rs:600:9
|
LL | _ if false => {}
| ^
@ -602,7 +660,7 @@ LL | _ if false => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/empty-types.rs:613:9
--> $DIR/empty-types.rs:603:9
|
LL | _x if false => {}
| ^^
@ -610,12 +668,13 @@ LL | _x if false => {}
= note: this pattern matches no values because `!` is uninhabited
error[E0004]: non-exhaustive patterns: `&_` not covered
--> $DIR/empty-types.rs:638:11
--> $DIR/empty-types.rs:628:11
|
LL | match ref_never {
| ^^^^^^^^^ pattern `&_` not covered
|
= note: the matched value is of type `&!`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
= note: references are always considered inhabited
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@ -625,7 +684,7 @@ LL + &_ => todo!()
|
error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
--> $DIR/empty-types.rs:654:11
--> $DIR/empty-types.rs:644:11
|
LL | match *ref_result_never {
| ^^^^^^^^^^^^^^^^^ pattern `Ok(_)` not covered
@ -636,6 +695,7 @@ note: `Result<!, !>` defined here
|
= note: not covered
= note: the matched value is of type `Result<!, !>`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Err(_) => {},
@ -643,7 +703,7 @@ LL + Ok(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> $DIR/empty-types.rs:674:11
--> $DIR/empty-types.rs:664:11
|
LL | match *x {
| ^^ pattern `Some(_)` not covered
@ -654,13 +714,14 @@ note: `Option<Result<!, !>>` defined here
|
= note: not covered
= note: the matched value is of type `Option<Result<!, !>>`
= note: `Result<!, !>` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
LL + Some(_) => todo!()
|
error: aborting due to 49 previous errors
error: aborting due to 64 previous errors
Some errors have detailed explanations: E0004, E0005.
For more information about an error, try `rustc --explain E0004`.

View File

@ -1,5 +1,4 @@
//@ revisions: normal min_exh_pats exhaustive_patterns never_pats
// gate-test-min_exhaustive_patterns
//@ revisions: normal exhaustive_patterns never_pats
//
// This tests correct handling of empty types in exhaustiveness checking.
//
@ -10,7 +9,6 @@
// This feature is useful to avoid `!` falling back to `()` all the time.
#![feature(never_type_fallback)]
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exh_pats, feature(min_exhaustive_patterns))]
#![cfg_attr(never_pats, feature(never_patterns))]
//[never_pats]~^ WARN the feature `never_patterns` is incomplete
#![allow(dead_code, unreachable_code)]
@ -68,19 +66,17 @@ fn basic(x: NeverBundle) {
let tuple_half_never: (u32, !) = x.tuple_half_never;
match tuple_half_never {}
//[normal,never_pats]~^ ERROR non-empty
match tuple_half_never {
(_, _) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
let tuple_never: (!, !) = x.tuple_never;
match tuple_never {}
//[normal,never_pats]~^ ERROR non-empty
match tuple_never {
_ => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match tuple_never {
(_, _) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match tuple_never.0 {}
match tuple_never.0 {
@ -91,44 +87,40 @@ fn basic(x: NeverBundle) {
match res_u32_never {}
//~^ ERROR non-exhaustive
match res_u32_never {
//[normal,never_pats]~^ ERROR non-exhaustive
Ok(_) => {}
}
match res_u32_never {
Ok(_) => {}
Err(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match res_u32_never {
//~^ ERROR non-exhaustive
Ok(0) => {}
Err(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
let Ok(_x) = res_u32_never;
//[normal,never_pats]~^ ERROR refutable
let Ok(_x) = res_u32_never.as_ref();
//~^ ERROR refutable
// Non-obvious difference: here there's an implicit dereference in the patterns, which makes the
// inner place !known_valid. `exhaustive_patterns` ignores this.
let Ok(_x) = &res_u32_never;
//[normal,min_exh_pats,never_pats]~^ ERROR refutable
//[normal,never_pats]~^ ERROR refutable
let result_never: Result<!, !> = x.result_never;
match result_never {}
//[normal,never_pats]~^ ERROR non-exhaustive
match result_never {
_ => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match result_never {
//[normal,never_pats]~^ ERROR non-exhaustive
Ok(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
}
@ -144,16 +136,15 @@ fn void_same_as_never(x: NeverBundle) {
}
let opt_void: Option<Void> = None;
match opt_void {
//[normal,never_pats]~^ ERROR non-exhaustive
None => {}
}
match opt_void {
None => {}
Some(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Some(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match opt_void {
None => {}
_ => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
let ref_void: &Void = &x.void;
@ -163,7 +154,7 @@ fn void_same_as_never(x: NeverBundle) {
}
let ref_opt_void: &Option<Void> = &None;
match *ref_opt_void {
//[normal,min_exh_pats,never_pats]~^ ERROR non-exhaustive
//[normal,never_pats]~^ ERROR non-exhaustive
None => {}
}
match *ref_opt_void {
@ -288,11 +279,11 @@ fn nested_validity_tracking(bundle: NeverBundle) {
_ => {} //~ ERROR unreachable pattern
}
match tuple_never {
(_, _) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
// These should be considered !known_valid and not warn unreachable.
@ -313,13 +304,13 @@ fn invalid_empty_match(bundle: NeverBundle) {
match *x {}
let x: &(u32, !) = &bundle.tuple_half_never;
match *x {} //[normal,min_exh_pats,never_pats]~ ERROR non-exhaustive
match *x {} //[normal,never_pats]~ ERROR non-exhaustive
let x: &(!, !) = &bundle.tuple_never;
match *x {} //[normal,min_exh_pats,never_pats]~ ERROR non-exhaustive
match *x {} //[normal,never_pats]~ ERROR non-exhaustive
let x: &Result<!, !> = &bundle.result_never;
match *x {} //[normal,min_exh_pats,never_pats]~ ERROR non-exhaustive
match *x {} //[normal,never_pats]~ ERROR non-exhaustive
let x: &[!; 3] = &bundle.array_3_never;
match *x {} //[normal,min_exh_pats,never_pats]~ ERROR non-exhaustive
match *x {} //[normal,never_pats]~ ERROR non-exhaustive
}
fn arrays_and_slices(x: NeverBundle) {
@ -327,7 +318,7 @@ fn arrays_and_slices(x: NeverBundle) {
match slice_never {}
//~^ ERROR non-empty
match slice_never {
//[normal,min_exh_pats,never_pats]~^ ERROR not covered
//[normal,never_pats]~^ ERROR not covered
[] => {}
}
match slice_never {
@ -336,7 +327,7 @@ fn arrays_and_slices(x: NeverBundle) {
[_, _, ..] => {}
}
match slice_never {
//[normal,min_exh_pats]~^ ERROR `&[]`, `&[_]` and `&[_, _]` not covered
//[normal]~^ ERROR `&[]`, `&[_]` and `&[_, _]` not covered
//[exhaustive_patterns]~^^ ERROR `&[]` not covered
//[never_pats]~^^^ ERROR `&[]`, `&[!]` and `&[!, !]` not covered
[_, _, _, ..] => {}
@ -350,7 +341,7 @@ fn arrays_and_slices(x: NeverBundle) {
_x => {}
}
match slice_never {
//[normal,min_exh_pats]~^ ERROR `&[]` and `&[_, ..]` not covered
//[normal]~^ ERROR `&[]` and `&[_, ..]` not covered
//[exhaustive_patterns]~^^ ERROR `&[]` not covered
//[never_pats]~^^^ ERROR `&[]` and `&[!, ..]` not covered
&[..] if false => {}
@ -364,15 +355,14 @@ fn arrays_and_slices(x: NeverBundle) {
let array_3_never: [!; 3] = x.array_3_never;
match array_3_never {}
//[normal,never_pats]~^ ERROR non-empty
match array_3_never {
_ => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match array_3_never {
[_, _, _] => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
[_, _, _] => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match array_3_never {
[_, ..] => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
[_, ..] => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
let ref_array_3_never: &[!; 3] = &array_3_never;
@ -414,22 +404,22 @@ fn bindings(x: NeverBundle) {
match opt_never {
None => {}
// !useful, !reachable
Some(_) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Some(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match opt_never {
None => {}
// !useful, !reachable
Some(_a) => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
Some(_a) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match opt_never {
None => {}
// !useful, !reachable
_ => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
match opt_never {
None => {}
// !useful, !reachable
_a => {} //[exhaustive_patterns,min_exh_pats]~ ERROR unreachable pattern
_a => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
}
// The scrutinee is known_valid, but under the `&` isn't anymore.
@ -450,7 +440,7 @@ fn bindings(x: NeverBundle) {
&_a => {}
}
match ref_opt_never {
//[normal,min_exh_pats,never_pats]~^ ERROR non-exhaustive
//[normal,never_pats]~^ ERROR non-exhaustive
&None => {}
}
match ref_opt_never {
@ -491,7 +481,7 @@ fn bindings(x: NeverBundle) {
ref _a => {}
}
match *ref_opt_never {
//[normal,min_exh_pats,never_pats]~^ ERROR non-exhaustive
//[normal,never_pats]~^ ERROR non-exhaustive
None => {}
}
match *ref_opt_never {
@ -539,7 +529,7 @@ fn bindings(x: NeverBundle) {
let ref_res_never: &Result<!, !> = &x.result_never;
match *ref_res_never {
//[normal,min_exh_pats,never_pats]~^ ERROR non-exhaustive
//[normal,never_pats]~^ ERROR non-exhaustive
// useful, reachable
Ok(_) => {}
}
@ -550,7 +540,7 @@ fn bindings(x: NeverBundle) {
_ => {}
}
match *ref_res_never {
//[normal,min_exh_pats,never_pats]~^ ERROR non-exhaustive
//[normal,never_pats]~^ ERROR non-exhaustive
// useful, !reachable
Ok(_a) => {}
}
@ -569,7 +559,7 @@ fn bindings(x: NeverBundle) {
let ref_tuple_half_never: &(u32, !) = &x.tuple_half_never;
match *ref_tuple_half_never {}
//[normal,min_exh_pats,never_pats]~^ ERROR non-empty
//[normal,never_pats]~^ ERROR non-empty
match *ref_tuple_half_never {
// useful, reachable
(_, _) => {}
@ -636,7 +626,7 @@ fn guards_and_validity(x: NeverBundle) {
_a if false => {}
}
match ref_never {
//[normal,min_exh_pats,never_pats]~^ ERROR non-exhaustive
//[normal,never_pats]~^ ERROR non-exhaustive
// useful, !reachable
&_a if false => {}
}
@ -652,7 +642,7 @@ fn guards_and_validity(x: NeverBundle) {
Err(_) => {}
}
match *ref_result_never {
//[normal,min_exh_pats]~^ ERROR `Ok(_)` not covered
//[normal]~^ ERROR `Ok(_)` not covered
//[never_pats]~^^ ERROR `Ok(!)` not covered
// useful, reachable
Ok(_) if false => {}
@ -672,7 +662,7 @@ fn diagnostics_subtlety(x: NeverBundle) {
// Regression test for diagnostics: don't report `Some(Ok(_))` and `Some(Err(_))`.
let x: &Option<Result<!, !>> = &None;
match *x {
//[normal,min_exh_pats]~^ ERROR `Some(_)` not covered
//[normal]~^ ERROR `Some(_)` not covered
//[never_pats]~^^ ERROR `Some(!)` not covered
None => {}
}

View File

@ -1,5 +1,4 @@
#![feature(never_type)]
#![feature(min_exhaustive_patterns)]
#![deny(unreachable_patterns)]
//~^ NOTE lint level is defined here

View File

@ -1,5 +1,5 @@
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:11:9
--> $DIR/explain-unreachable-pats.rs:10:9
|
LL | (1 | 2,) => {}
| -------- matches all the values already
@ -8,19 +8,19 @@ LL | (2,) => {}
| ^^^^ unreachable pattern
|
note: the lint level is defined here
--> $DIR/explain-unreachable-pats.rs:3:9
--> $DIR/explain-unreachable-pats.rs:2:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:22:9
--> $DIR/explain-unreachable-pats.rs:21:9
|
LL | (1 | 2,) => {}
| ^^^^^^^^ unreachable pattern
|
note: these patterns collectively make the last one unreachable
--> $DIR/explain-unreachable-pats.rs:22:9
--> $DIR/explain-unreachable-pats.rs:21:9
|
LL | (1,) => {}
| ---- matches some of the same values
@ -32,7 +32,7 @@ LL | (1 | 2,) => {}
| ^^^^^^^^ collectively making this unreachable
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:33:9
--> $DIR/explain-unreachable-pats.rs:32:9
|
LL | Err(_) => {}
| ^^^^^^
@ -40,7 +40,7 @@ LL | Err(_) => {}
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:46:9
--> $DIR/explain-unreachable-pats.rs:45:9
|
LL | (Err(_), Err(_)) => {}
| ^^^^^^^^^^^^^^^^
@ -48,7 +48,7 @@ LL | (Err(_), Err(_)) => {}
= note: this pattern matches no values because `Void2` is uninhabited
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:52:9
--> $DIR/explain-unreachable-pats.rs:51:9
|
LL | (Err(_), Err(_)) => {}
| ^^^^^^^^^^^^^^^^
@ -56,7 +56,7 @@ LL | (Err(_), Err(_)) => {}
= note: this pattern matches no values because `Void1` is uninhabited
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:61:11
--> $DIR/explain-unreachable-pats.rs:60:11
|
LL | if let (0
| - matches all the values already
@ -65,13 +65,13 @@ LL | | 0, _) = (0, 0) {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:71:9
--> $DIR/explain-unreachable-pats.rs:70:9
|
LL | (_, true) => {}
| ^^^^^^^^^ unreachable pattern
|
note: these patterns collectively make the last one unreachable
--> $DIR/explain-unreachable-pats.rs:71:9
--> $DIR/explain-unreachable-pats.rs:70:9
|
LL | (true, _) => {}
| --------- matches some of the same values
@ -83,7 +83,7 @@ LL | (_, true) => {}
| ^^^^^^^^^ collectively making this unreachable
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:84:9
--> $DIR/explain-unreachable-pats.rs:83:9
|
LL | (true, _) => {}
| --------- matches all the values already
@ -92,7 +92,7 @@ LL | (true, true) => {}
| ^^^^^^^^^^^^ unreachable pattern
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:96:9
--> $DIR/explain-unreachable-pats.rs:95:9
|
LL | (_, true, 0..10) => {}
| ---------------- matches all the values already

View File

@ -1,5 +1,4 @@
#![feature(never_type)]
#![feature(min_exhaustive_patterns)]
#![feature(type_alias_impl_trait)]
#![feature(non_exhaustive_omitted_patterns_lint)]
#![deny(unreachable_patterns)]

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/impl-trait.rs:17:13
--> $DIR/impl-trait.rs:16:13
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `Void` is uninhabited
note: the lint level is defined here
--> $DIR/impl-trait.rs:5:9
--> $DIR/impl-trait.rs:4:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/impl-trait.rs:31:13
--> $DIR/impl-trait.rs:30:13
|
LL | _ => {}
| ^
@ -20,7 +20,7 @@ LL | _ => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/impl-trait.rs:45:13
--> $DIR/impl-trait.rs:44:13
|
LL | Some(_) => {}
| ^^^^^^^
@ -28,7 +28,7 @@ LL | Some(_) => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/impl-trait.rs:49:13
--> $DIR/impl-trait.rs:48:13
|
LL | None => {}
| ---- matches all the values already
@ -36,7 +36,7 @@ LL | _ => {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/impl-trait.rs:59:13
--> $DIR/impl-trait.rs:58:13
|
LL | Some(_) => {}
| ^^^^^^^
@ -44,7 +44,7 @@ LL | Some(_) => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/impl-trait.rs:63:13
--> $DIR/impl-trait.rs:62:13
|
LL | None => {}
| ---- matches all the values already
@ -52,7 +52,7 @@ LL | _ => {}
| ^ unreachable pattern
error: unreachable pattern
--> $DIR/impl-trait.rs:76:9
--> $DIR/impl-trait.rs:75:9
|
LL | _ => {}
| ^
@ -60,7 +60,7 @@ LL | _ => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/impl-trait.rs:86:9
--> $DIR/impl-trait.rs:85:9
|
LL | _ => {}
| - matches any value
@ -68,7 +68,7 @@ LL | Some((a, b)) => {}
| ^^^^^^^^^^^^ unreachable pattern
error: unreachable pattern
--> $DIR/impl-trait.rs:94:13
--> $DIR/impl-trait.rs:93:13
|
LL | _ => {}
| ^
@ -76,7 +76,7 @@ LL | _ => {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/impl-trait.rs:105:9
--> $DIR/impl-trait.rs:104:9
|
LL | Some((a, b)) => {}
| ------------ matches all the values already
@ -84,7 +84,7 @@ LL | Some((mut x, mut y)) => {
| ^^^^^^^^^^^^^^^^^^^^ unreachable pattern
error: unreachable pattern
--> $DIR/impl-trait.rs:124:13
--> $DIR/impl-trait.rs:123:13
|
LL | _ => {}
| - matches any value
@ -92,7 +92,7 @@ LL | Rec { n: 0, w: Some(Rec { n: 0, w: _ }) } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern
error: unreachable pattern
--> $DIR/impl-trait.rs:138:13
--> $DIR/impl-trait.rs:137:13
|
LL | _ => {}
| ^
@ -100,7 +100,7 @@ LL | _ => {}
= note: this pattern matches no values because `SecretelyVoid` is uninhabited
error: unreachable pattern
--> $DIR/impl-trait.rs:151:13
--> $DIR/impl-trait.rs:150:13
|
LL | _ => {}
| ^
@ -108,7 +108,7 @@ LL | _ => {}
= note: this pattern matches no values because `SecretelyDoubleVoid` is uninhabited
error[E0004]: non-exhaustive patterns: type `impl Copy` is non-empty
--> $DIR/impl-trait.rs:23:11
--> $DIR/impl-trait.rs:22:11
|
LL | match return_never_rpit(x) {}
| ^^^^^^^^^^^^^^^^^^^^
@ -122,7 +122,7 @@ LL + }
|
error[E0004]: non-exhaustive patterns: type `T` is non-empty
--> $DIR/impl-trait.rs:37:11
--> $DIR/impl-trait.rs:36:11
|
LL | match return_never_tait(x) {}
| ^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered
--> $DIR/match-privately-empty.rs:15:11
--> $DIR/match-privately-empty.rs:14:11
|
LL | match private::DATA {
| ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered

View File

@ -0,0 +1,21 @@
error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered
--> $DIR/match-privately-empty.rs:14:11
|
LL | match private::DATA {
| ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered
|
note: `Option<Private>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
::: $SRC_DIR/core/src/option.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Option<Private>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Some(private::Private { misc: false, .. }) => {},
LL + Some(Private { misc: true, .. }) => todo!()
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.

View File

@ -1,6 +1,5 @@
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]
mod private {

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `&[]` not covered
--> $DIR/slice_of_empty.rs:21:11
--> $DIR/slice_of_empty.rs:20:11
|
LL | match nevers {
| ^^^^^^ pattern `&[]` not covered

View File

@ -0,0 +1,30 @@
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
--> $DIR/slice_of_empty.rs:9:11
|
LL | match nevers {
| ^^^^^^ pattern `&[_, ..]` not covered
|
= note: the matched value is of type `&[!]`
= note: `!` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ &[] => (),
LL ~ &[_, ..] => todo!(),
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice_of_empty.rs:20:11
|
LL | match nevers {
| ^^^^^^ patterns `&[]` and `&[_, _, ..]` not covered
|
= note: the matched value is of type `&[!]`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ &[_] => (),
LL ~ &[] | &[_, _, ..] => todo!(),
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0004`.

View File

@ -1,6 +1,5 @@
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]
#![deny(unreachable_patterns)]
@ -8,7 +7,7 @@ fn main() {}
fn foo(nevers: &[!]) {
match nevers {
//[min_exhaustive_patterns]~^ ERROR non-exhaustive patterns: `&[_, ..]` not covered
//[normal]~^ ERROR non-exhaustive patterns: `&[_, ..]` not covered
&[] => (),
};
@ -20,7 +19,7 @@ fn foo(nevers: &[!]) {
match nevers {
//[exhaustive_patterns]~^ ERROR non-exhaustive patterns: `&[]` not covered
//[min_exhaustive_patterns]~^^ ERROR non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
//[normal]~^^ ERROR non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
&[_] => (),
};
}

View File

@ -5,7 +5,6 @@
// `Ty::is_inhabited_from` function.
#![feature(never_type)]
#![feature(never_type_fallback)]
#![feature(min_exhaustive_patterns)]
#![deny(unreachable_patterns)]
macro_rules! assert_empty {

View File

@ -1,6 +1,4 @@
#![feature(never_type, never_type_fallback)]
#![feature(min_exhaustive_patterns)]
#![allow(unreachable_code)]
#![deny(unreachable_patterns)]

View File

@ -1,12 +1,12 @@
error: unreachable pattern
--> $DIR/unreachable-loop-patterns.rs:18:9
--> $DIR/unreachable-loop-patterns.rs:16:9
|
LL | for _ in unimplemented!() as Void {}
| ^
|
= note: this pattern matches no values because `Void` is uninhabited
note: the lint level is defined here
--> $DIR/unreachable-loop-patterns.rs:5:9
--> $DIR/unreachable-loop-patterns.rs:3:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^

View File

@ -11,22 +11,22 @@ macro_rules! never {
}
fn no_arms_or_guards(x: Void) {
match None::<Void> {
match &None::<Void> {
Some(!) => {}
//~^ ERROR a never pattern is always unreachable
None => {}
}
match None::<Void> { //~ ERROR: `Some(!)` not covered
match &None::<Void> { //~ ERROR: `&Some(!)` not covered
Some(!) if true,
//~^ ERROR guard on a never pattern
None => {}
}
match None::<Void> { //~ ERROR: `Some(!)` not covered
match &None::<Void> { //~ ERROR: `&Some(!)` not covered
Some(!) if true => {}
//~^ ERROR a never pattern is always unreachable
None => {}
}
match None::<Void> {
match &None::<Void> {
Some(never!()) => {}
//~^ ERROR a never pattern is always unreachable
None => {}

View File

@ -31,40 +31,42 @@ LL | Some(never!()) => {}
| this will never be executed
| help: remove this expression
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
--> $DIR/check.rs:19:11
|
LL | match None::<Void> {
| ^^^^^^^^^^^^ pattern `Some(!)` not covered
LL | match &None::<Void> {
| ^^^^^^^^^^^^^ pattern `&Some(!)` not covered
|
note: `Option<Void>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
::: $SRC_DIR/core/src/option.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Option<Void>`
= note: the matched value is of type `&Option<Void>`
= note: `Void` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
LL + Some(!)
LL + &Some(!)
|
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
--> $DIR/check.rs:24:11
|
LL | match None::<Void> {
| ^^^^^^^^^^^^ pattern `Some(!)` not covered
LL | match &None::<Void> {
| ^^^^^^^^^^^^^ pattern `&Some(!)` not covered
|
note: `Option<Void>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
::: $SRC_DIR/core/src/option.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Option<Void>`
= note: the matched value is of type `&Option<Void>`
= note: `Void` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => {},
LL + Some(!)
LL + &Some(!)
|
error: aborting due to 6 previous errors

View File

@ -1,5 +1,5 @@
error: mismatched types
--> $DIR/typeck.rs:25:9
--> $DIR/typeck.rs:24:9
|
LL | !,
| ^ a never pattern must be used on an uninhabited type
@ -7,7 +7,7 @@ LL | !,
= note: the matched value is of type `()`
error: mismatched types
--> $DIR/typeck.rs:29:9
--> $DIR/typeck.rs:28:9
|
LL | !,
| ^ a never pattern must be used on an uninhabited type
@ -15,7 +15,7 @@ LL | !,
= note: the matched value is of type `(i32, bool)`
error: mismatched types
--> $DIR/typeck.rs:33:13
--> $DIR/typeck.rs:32:13
|
LL | (_, !),
| ^ a never pattern must be used on an uninhabited type
@ -23,7 +23,7 @@ LL | (_, !),
= note: the matched value is of type `bool`
error: mismatched types
--> $DIR/typeck.rs:38:14
--> $DIR/typeck.rs:37:14
|
LL | Some(!),
| ^ a never pattern must be used on an uninhabited type
@ -31,7 +31,7 @@ LL | Some(!),
= note: the matched value is of type `i32`
error: mismatched types
--> $DIR/typeck.rs:45:9
--> $DIR/typeck.rs:44:9
|
LL | !,
| ^ a never pattern must be used on an uninhabited type
@ -39,7 +39,7 @@ LL | !,
= note: the matched value is of type `()`
error: mismatched types
--> $DIR/typeck.rs:52:9
--> $DIR/typeck.rs:51:9
|
LL | !,
| ^ a never pattern must be used on an uninhabited type
@ -47,7 +47,7 @@ LL | !,
= note: the matched value is of type `Option<Void>`
error: mismatched types
--> $DIR/typeck.rs:57:9
--> $DIR/typeck.rs:56:9
|
LL | !,
| ^ a never pattern must be used on an uninhabited type
@ -55,7 +55,7 @@ LL | !,
= note: the matched value is of type `[Void]`
error: mismatched types
--> $DIR/typeck.rs:63:9
--> $DIR/typeck.rs:62:9
|
LL | !,
| ^ a never pattern must be used on an uninhabited type

View File

@ -2,7 +2,6 @@
//@[pass] check-pass
//@[fail] check-fail
#![feature(never_patterns)]
#![feature(min_exhaustive_patterns)]
#![allow(incomplete_features)]
#[derive(Copy, Clone)]

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/unreachable.rs:17:9
--> $DIR/unreachable.rs:16:9
|
LL | Err(!),
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
note: the lint level is defined here
--> $DIR/unreachable.rs:7:9
--> $DIR/unreachable.rs:6:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:20:19
--> $DIR/unreachable.rs:19:19
|
LL | let (Ok(_x) | Err(!)) = res_void;
| ^^^^^^
@ -20,7 +20,7 @@ LL | let (Ok(_x) | Err(!)) = res_void;
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:22:12
--> $DIR/unreachable.rs:21:12
|
LL | if let Err(!) = res_void {}
| ^^^^^^
@ -28,7 +28,7 @@ LL | if let Err(!) = res_void {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:24:24
--> $DIR/unreachable.rs:23:24
|
LL | if let (Ok(true) | Err(!)) = res_void {}
| ^^^^^^
@ -36,7 +36,7 @@ LL | if let (Ok(true) | Err(!)) = res_void {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:26:23
--> $DIR/unreachable.rs:25:23
|
LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
| ^^^^^^
@ -44,7 +44,7 @@ LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:30:18
--> $DIR/unreachable.rs:29:18
|
LL | fn foo((Ok(_x) | Err(!)): Result<bool, Void>) {}
| ^^^^^^

View File

@ -0,0 +1,44 @@
error: unreachable pattern
--> $DIR/unreachable.rs:16:9
|
LL | Err(!),
| ^^^^^^
|
note: the lint level is defined here
--> $DIR/unreachable.rs:6:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:19:19
|
LL | let (Ok(_x) | Err(!)) = res_void;
| ^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:21:12
|
LL | if let Err(!) = res_void {}
| ^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:23:24
|
LL | if let (Ok(true) | Err(!)) = res_void {}
| ^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:25:23
|
LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
| ^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:29:18
|
LL | fn foo((Ok(_x) | Err(!)): Result<bool, Void>) {}
| ^^^^^^
error: aborting due to 6 previous errors

View File

@ -1,8 +1,5 @@
//@ revisions: normal exh_pats
//@[normal] check-pass
#![feature(never_patterns)]
#![allow(incomplete_features)]
#![cfg_attr(exh_pats, feature(min_exhaustive_patterns))]
#![allow(dead_code, unreachable_code)]
#![deny(unreachable_patterns)]
@ -15,17 +12,17 @@ fn main() {
match res_void {
Ok(_x) => {}
Err(!),
//[exh_pats]~^ ERROR unreachable
//~^ ERROR unreachable
}
let (Ok(_x) | Err(!)) = res_void;
//[exh_pats]~^ ERROR unreachable
//~^ ERROR unreachable
if let Err(!) = res_void {}
//[exh_pats]~^ ERROR unreachable
//~^ ERROR unreachable
if let (Ok(true) | Err(!)) = res_void {}
//[exh_pats]~^ ERROR unreachable
//~^ ERROR unreachable
for (Ok(mut _x) | Err(!)) in [res_void] {}
//[exh_pats]~^ ERROR unreachable
//~^ ERROR unreachable
}
fn foo((Ok(_x) | Err(!)): Result<bool, Void>) {}
//[exh_pats]~^ ERROR unreachable
//~^ ERROR unreachable

View File

@ -0,0 +1,55 @@
error: unreachable pattern
--> $DIR/unreachable.rs:14:9
|
LL | Err(!),
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
note: the lint level is defined here
--> $DIR/unreachable.rs:4:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:17:19
|
LL | let (Ok(_x) | Err(!)) = res_void;
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:19:12
|
LL | if let Err(!) = res_void {}
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:21:24
|
LL | if let (Ok(true) | Err(!)) = res_void {}
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:23:23
|
LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
error: unreachable pattern
--> $DIR/unreachable.rs:27:18
|
LL | fn foo((Ok(_x) | Err(!)): Result<bool, Void>) {}
| ^^^^^^
|
= note: this pattern matches no values because `Void` is uninhabited
error: aborting due to 6 previous errors

View File

@ -1,3 +1,4 @@
//@ check-pass
#![feature(never_type)]
#[non_exhaustive]
@ -28,24 +29,24 @@ pub struct IndirectUninhabitedVariants(UninhabitedVariants);
struct A;
// This test checks that an empty match on a non-exhaustive uninhabited type through a level of
// indirection from the defining crate will not compile without `#![feature(exhaustive_patterns)]`.
// indirection from the defining crate compiles.
fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(
x: IndirectUninhabitedVariants,
) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn main() {}

View File

@ -1,79 +0,0 @@
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty
--> $DIR/indirect_match_same_crate.rs:34:11
|
LL | match x {}
| ^
|
note: `IndirectUninhabitedEnum` defined here
--> $DIR/indirect_match_same_crate.rs:20:12
|
LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum);
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: the matched value is of type `IndirectUninhabitedEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match x {
LL + _ => todo!(),
LL ~ }
|
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty
--> $DIR/indirect_match_same_crate.rs:38:11
|
LL | match x {}
| ^
|
note: `IndirectUninhabitedStruct` defined here
--> $DIR/indirect_match_same_crate.rs:22:12
|
LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the matched value is of type `IndirectUninhabitedStruct`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match x {
LL + _ => todo!(),
LL ~ }
|
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty
--> $DIR/indirect_match_same_crate.rs:42:11
|
LL | match x {}
| ^
|
note: `IndirectUninhabitedTupleStruct` defined here
--> $DIR/indirect_match_same_crate.rs:24:12
|
LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the matched value is of type `IndirectUninhabitedTupleStruct`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match x {
LL + _ => todo!(),
LL ~ }
|
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty
--> $DIR/indirect_match_same_crate.rs:48:11
|
LL | match x {}
| ^
|
note: `IndirectUninhabitedVariants` defined here
--> $DIR/indirect_match_same_crate.rs:26:12
|
LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the matched value is of type `IndirectUninhabitedVariants`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match x {
LL + _ => todo!(),
LL ~ }
|
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0004`.

View File

@ -1,6 +1,5 @@
//@ aux-build:uninhabited.rs
#![deny(unreachable_patterns)]
#![feature(min_exhaustive_patterns)]
#![feature(never_type)]
extern crate uninhabited;

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty
--> $DIR/indirect_match_with_exhaustive_patterns.rs:23:11
--> $DIR/indirect_match_with_exhaustive_patterns.rs:22:11
|
LL | match x {}
| ^
@ -18,7 +18,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty
--> $DIR/indirect_match_with_exhaustive_patterns.rs:27:11
--> $DIR/indirect_match_with_exhaustive_patterns.rs:26:11
|
LL | match x {}
| ^
@ -37,7 +37,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty
--> $DIR/indirect_match_with_exhaustive_patterns.rs:31:11
--> $DIR/indirect_match_with_exhaustive_patterns.rs:30:11
|
LL | match x {}
| ^
@ -56,7 +56,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty
--> $DIR/indirect_match_with_exhaustive_patterns.rs:37:11
--> $DIR/indirect_match_with_exhaustive_patterns.rs:36:11
|
LL | match x {}
| ^

View File

@ -1,7 +1,6 @@
//@ check-pass
#![deny(unreachable_patterns)]
#![feature(min_exhaustive_patterns)]
#![feature(never_type)]
#[non_exhaustive]

View File

@ -1,3 +1,4 @@
//@ check-pass
#![feature(never_type)]
#[non_exhaustive]
@ -27,15 +28,15 @@ fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A {
}
fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A {
match x {} //~ ERROR non-exhaustive patterns
match x {}
}
fn main() {}

View File

@ -1,64 +0,0 @@
error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty
--> $DIR/match_same_crate.rs:30:11
|
LL | match x {}
| ^
|
note: `UninhabitedStruct` defined here
--> $DIR/match_same_crate.rs:8:12
|
LL | pub struct UninhabitedStruct {
| ^^^^^^^^^^^^^^^^^
= note: the matched value is of type `UninhabitedStruct`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match x {
LL + _ => todo!(),
LL ~ }
|
error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty
--> $DIR/match_same_crate.rs:34:11
|
LL | match x {}
| ^
|
note: `UninhabitedTupleStruct` defined here
--> $DIR/match_same_crate.rs:13:12
|
LL | pub struct UninhabitedTupleStruct(!);
| ^^^^^^^^^^^^^^^^^^^^^^
= note: the matched value is of type `UninhabitedTupleStruct`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ match x {
LL + _ => todo!(),
LL ~ }
|
error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
--> $DIR/match_same_crate.rs:38:11
|
LL | match x {}
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
|
note: `UninhabitedVariants` defined here
--> $DIR/match_same_crate.rs:15:10
|
LL | pub enum UninhabitedVariants {
| ^^^^^^^^^^^^^^^^^^^
LL | #[non_exhaustive] Tuple(!),
| ----- not covered
LL | #[non_exhaustive] Struct { x: ! }
| ------ not covered
= note: the matched value is of type `UninhabitedVariants`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ match x {
LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(),
LL ~ }
|
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0004`.

View File

@ -1,6 +1,5 @@
//@ aux-build:uninhabited.rs
#![deny(unreachable_patterns)]
#![feature(min_exhaustive_patterns)]
#![feature(never_type)]
extern crate uninhabited;

View File

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty
--> $DIR/match_with_exhaustive_patterns.rs:22:11
--> $DIR/match_with_exhaustive_patterns.rs:21:11
|
LL | match x {}
| ^
@ -18,7 +18,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty
--> $DIR/match_with_exhaustive_patterns.rs:26:11
--> $DIR/match_with_exhaustive_patterns.rs:25:11
|
LL | match x {}
| ^
@ -37,7 +37,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty
--> $DIR/match_with_exhaustive_patterns.rs:30:11
--> $DIR/match_with_exhaustive_patterns.rs:29:11
|
LL | match x {}
| ^
@ -56,7 +56,7 @@ LL ~ }
|
error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
--> $DIR/match_with_exhaustive_patterns.rs:34:11
--> $DIR/match_with_exhaustive_patterns.rs:33:11
|
LL | match x {}
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered

View File

@ -1,7 +1,6 @@
//@ check-pass
#![deny(unreachable_patterns)]
#![feature(min_exhaustive_patterns)]
#![feature(never_type)]
#[non_exhaustive]

View File

@ -1,7 +1,6 @@
//@ aux-build:uninhabited.rs
//@ build-pass (FIXME(62277): could be check-pass?)
#![deny(unreachable_patterns)]
#![feature(min_exhaustive_patterns)]
extern crate uninhabited;

View File

@ -1,5 +1,4 @@
#![deny(unreachable_patterns)]
#![feature(min_exhaustive_patterns)]
#![feature(never_type)]
#[non_exhaustive]

View File

@ -1,5 +1,5 @@
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:52:9
--> $DIR/patterns_same_crate.rs:51:9
|
LL | Some(_x) => (),
| ^^^^^^^^
@ -12,7 +12,7 @@ LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:57:9
--> $DIR/patterns_same_crate.rs:56:9
|
LL | Some(_x) => (),
| ^^^^^^^^
@ -20,7 +20,7 @@ LL | Some(_x) => (),
= note: this pattern matches no values because `UninhabitedVariants` is uninhabited
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:61:15
--> $DIR/patterns_same_crate.rs:60:15
|
LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -28,7 +28,7 @@ LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabite
= note: this pattern matches no values because `!` is uninhabited
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:65:15
--> $DIR/patterns_same_crate.rs:64:15
|
LL | while let Some(_x) = uninhabited_struct() {
| ^^^^^^^^
@ -36,7 +36,7 @@ LL | while let Some(_x) = uninhabited_struct() {
= note: this pattern matches no values because `UninhabitedStruct` is uninhabited
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:68:15
--> $DIR/patterns_same_crate.rs:67:15
|
LL | while let Some(_x) = uninhabited_tuple_struct() {
| ^^^^^^^^

View File

@ -31,7 +31,6 @@ impl<U, V> Try for MyResult<U, V> {
impl<U, V, W> FromResidual<MyResult<Never, V>> for MyResult<U, W> where V: Into<W> {
fn from_residual(x: MyResult<Never, V>) -> Self {
match x {
MyResult::Awesome(u) => match u {},
MyResult::Terrible(e) => MyResult::Terrible(e.into()),
}
}
@ -42,7 +41,6 @@ type ResultResidual<E> = Result<std::convert::Infallible, E>;
impl<U, V, W> FromResidual<ResultResidual<V>> for MyResult<U, W> where V: Into<W> {
fn from_residual(x: ResultResidual<V>) -> Self {
match x {
Ok(v) => match v {}
Err(e) => MyResult::Terrible(e.into()),
}
}
@ -51,7 +49,6 @@ impl<U, V, W> FromResidual<ResultResidual<V>> for MyResult<U, W> where V: Into<W
impl<U, V, W> FromResidual<MyResult<Never, V>> for Result<U, W> where V: Into<W> {
fn from_residual(x: MyResult<Never, V>) -> Self {
match x {
MyResult::Awesome(u) => match u {},
MyResult::Terrible(e) => Err(e.into()),
}
}

View File

@ -1,7 +1,5 @@
//@ check-pass
#![feature(min_exhaustive_patterns)]
enum Void {}
fn main() {
let a: Option<Void> = None;

View File

@ -1,5 +1,5 @@
error[E0005]: refutable pattern in local binding
--> $DIR/uninhabited-irrefutable.rs:31:9
--> $DIR/uninhabited-irrefutable.rs:30:9
|
LL | let Foo::D(_y, _z) = x;
| ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered
@ -7,7 +7,7 @@ LL | let Foo::D(_y, _z) = x;
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Foo` defined here
--> $DIR/uninhabited-irrefutable.rs:20:6
--> $DIR/uninhabited-irrefutable.rs:19:6
|
LL | enum Foo {
| ^^^

View File

@ -0,0 +1,26 @@
error[E0005]: refutable pattern in local binding
--> $DIR/uninhabited-irrefutable.rs:30:9
|
LL | let Foo::D(_y, _z) = x;
| ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Foo` defined here
--> $DIR/uninhabited-irrefutable.rs:19:6
|
LL | enum Foo {
| ^^^
LL |
LL | A(foo::SecretlyEmpty),
| - not covered
= note: pattern `Foo::A(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
= note: the matched value is of type `Foo`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Foo::D(_y, _z) = x else { todo!() };
| ++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0005`.

View File

@ -1,6 +1,5 @@
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]
mod foo {

View File

@ -15,10 +15,10 @@ fn main() {
let _ = match x {}; //~ ERROR non-exhaustive
let x: (Void,) = unsafe { zeroed() };
let _ = match x {}; //~ ERROR non-exhaustive
let _ = match x {};
let x: [Void; 1] = unsafe { zeroed() };
let _ = match x {}; //~ ERROR non-exhaustive
let _ = match x {};
let x: &[Void] = unsafe { zeroed() };
let _ = match x { //~ ERROR non-exhaustive
@ -29,11 +29,10 @@ fn main() {
let _ = match x {}; // okay
let x: Result<u32, Void> = Ok(23);
let _ = match x { //~ ERROR non-exhaustive
let _ = match x {
Ok(x) => x,
};
let x: Result<u32, Void> = Ok(23);
let Ok(x) = x;
//~^ ERROR refutable
}

View File

@ -36,34 +36,6 @@ LL + _ => todo!(),
LL ~ };
|
error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty
--> $DIR/uninhabited-matches-feature-gated.rs:18:19
|
LL | let _ = match x {};
| ^
|
= note: the matched value is of type `(Void,)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ let _ = match x {
LL + _ => todo!(),
LL ~ };
|
error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty
--> $DIR/uninhabited-matches-feature-gated.rs:21:19
|
LL | let _ = match x {};
| ^
|
= note: the matched value is of type `[Void; 1]`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ let _ = match x {
LL + _ => todo!(),
LL ~ };
|
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
--> $DIR/uninhabited-matches-feature-gated.rs:24:19
|
@ -71,45 +43,13 @@ LL | let _ = match x {
| ^ pattern `&[_, ..]` not covered
|
= note: the matched value is of type `&[Void]`
= note: `Void` is uninhabited but is not being matched by value, so a wildcard `_` is required
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ &[] => (),
LL ~ &[_, ..] => todo!(),
|
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
--> $DIR/uninhabited-matches-feature-gated.rs:32:19
|
LL | let _ = match x {
| ^ pattern `Err(_)` not covered
|
note: `Result<u32, Void>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<u32, Void>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ Ok(x) => x,
LL ~ Err(_) => todo!(),
|
error: aborting due to 3 previous errors
error[E0005]: refutable pattern in local binding
--> $DIR/uninhabited-matches-feature-gated.rs:37:9
|
LL | let Ok(x) = x;
| ^^^^^ pattern `Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Result<u32, Void>`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(x) = x else { todo!() };
| ++++++++++++++++
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0004, E0005.
For more information about an error, try `rustc --explain E0004`.
For more information about this error, try `rustc --explain E0004`.

View File

@ -1,6 +1,5 @@
#![feature(box_patterns)]
#![feature(never_type)]
#![feature(min_exhaustive_patterns)]
#![deny(unreachable_patterns)]
mod foo {

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/uninhabited-patterns.rs:30:9
--> $DIR/uninhabited-patterns.rs:29:9
|
LL | Ok(box _) => (),
| ^^^^^^^^^
|
= note: this pattern matches no values because `NotSoSecretlyEmpty` is uninhabited
note: the lint level is defined here
--> $DIR/uninhabited-patterns.rs:4:9
--> $DIR/uninhabited-patterns.rs:3:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/uninhabited-patterns.rs:39:9
--> $DIR/uninhabited-patterns.rs:38:9
|
LL | Err(Ok(_y)) => (),
| ^^^^^^^^^^^
@ -20,7 +20,7 @@ LL | Err(Ok(_y)) => (),
= note: this pattern matches no values because `NotSoSecretlyEmpty` is uninhabited
error: unreachable pattern
--> $DIR/uninhabited-patterns.rs:42:15
--> $DIR/uninhabited-patterns.rs:41:15
|
LL | while let Some(_y) = foo() {
| ^^^^^^^^