From 50061f3b11f51d7a6e3acd8ce793a1f17f99b597 Mon Sep 17 00:00:00 2001 From: dianne Date: Fri, 4 Jul 2025 21:17:40 -0700 Subject: always check for mixed deref pattern and normal constructors This makes it work for box patterns and in rust-analyzer. --- compiler/rustc_pattern_analysis/src/checks.rs | 50 +++++++++++++++++ compiler/rustc_pattern_analysis/src/lib.rs | 10 ++++ compiler/rustc_pattern_analysis/src/rustc.rs | 67 +++++------------------ compiler/rustc_pattern_analysis/src/usefulness.rs | 5 +- 4 files changed, 79 insertions(+), 53 deletions(-) create mode 100644 compiler/rustc_pattern_analysis/src/checks.rs (limited to 'compiler/rustc_pattern_analysis/src') diff --git a/compiler/rustc_pattern_analysis/src/checks.rs b/compiler/rustc_pattern_analysis/src/checks.rs new file mode 100644 index 00000000000..88ccaa1e0e5 --- /dev/null +++ b/compiler/rustc_pattern_analysis/src/checks.rs @@ -0,0 +1,50 @@ +//! Contains checks that must be run to validate matches before performing usefulness analysis. + +use crate::constructor::Constructor::*; +use crate::pat_column::PatternColumn; +use crate::{MatchArm, PatCx}; + +/// Validate that deref patterns and normal constructors aren't used to match on the same place. +pub(crate) fn detect_mixed_deref_pat_ctors<'p, Cx: PatCx>( + cx: &Cx, + arms: &[MatchArm<'p, Cx>], +) -> Result<(), Cx::Error> { + let pat_column = PatternColumn::new(arms); + detect_mixed_deref_pat_ctors_inner(cx, &pat_column) +} + +fn detect_mixed_deref_pat_ctors_inner<'p, Cx: PatCx>( + cx: &Cx, + column: &PatternColumn<'p, Cx>, +) -> Result<(), Cx::Error> { + let Some(ty) = column.head_ty() else { + return Ok(()); + }; + + // Check for a mix of deref patterns and normal constructors. + let mut deref_pat = None; + let mut normal_pat = None; + for pat in column.iter() { + match pat.ctor() { + // The analysis can handle mixing deref patterns with wildcards and opaque patterns. + Wildcard | Opaque(_) => {} + DerefPattern(_) => deref_pat = Some(pat), + // Nothing else can be compared to deref patterns in `Constructor::is_covered_by`. + _ => normal_pat = Some(pat), + } + } + if let Some(deref_pat) = deref_pat + && let Some(normal_pat) = normal_pat + { + return Err(cx.report_mixed_deref_pat_ctors(deref_pat, normal_pat)); + } + + // Specialize and recurse into the patterns' fields. + let set = column.analyze_ctors(cx, &ty)?; + for ctor in set.present { + for specialized_column in column.specialize(cx, &ty, &ctor).iter() { + detect_mixed_deref_pat_ctors_inner(cx, specialized_column)?; + } + } + Ok(()) +} diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 2b85d7b26ce..129fd38725c 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -8,6 +8,7 @@ #![allow(unused_crate_dependencies)] // tidy-alphabetical-end +pub(crate) mod checks; pub mod constructor; #[cfg(feature = "rustc")] pub mod errors; @@ -107,6 +108,15 @@ pub trait PatCx: Sized + fmt::Debug { _gapped_with: &[&DeconstructedPat], ) { } + + /// The current implementation of deref patterns requires that they can't match on the same + /// place as a normal constructor. Since this isn't caught by type-checking, we check it in the + /// `PatCx` before running the analysis. This reports an error if the check fails. + fn report_mixed_deref_pat_ctors( + &self, + deref_pat: &DeconstructedPat, + normal_pat: &DeconstructedPat, + ) -> Self::Error; } /// The arm of a match expression. diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index e53cebc59ba..e9795126db6 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -1027,6 +1027,21 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { ); } } + + fn report_mixed_deref_pat_ctors( + &self, + deref_pat: &crate::pat::DeconstructedPat, + normal_pat: &crate::pat::DeconstructedPat, + ) -> Self::Error { + let deref_pattern_label = deref_pat.data().span; + let normal_constructor_label = normal_pat.data().span; + self.tcx.dcx().emit_err(errors::MixedDerefPatternConstructors { + spans: vec![deref_pattern_label, normal_constructor_label], + smart_pointer_ty: deref_pat.ty().inner(), + deref_pattern_label, + normal_constructor_label, + }) + } } /// Recursively expand this pattern into its subpatterns. Only useful for or-patterns. @@ -1055,13 +1070,6 @@ pub fn analyze_match<'p, 'tcx>( ) -> Result, ErrorGuaranteed> { let scrut_ty = tycx.reveal_opaque_ty(scrut_ty); - // The analysis doesn't support deref patterns mixed with normal constructors; error if present. - // FIXME(deref_patterns): This only needs to run when a deref pattern was found during lowering. - if tycx.tcx.features().deref_patterns() { - let pat_column = PatternColumn::new(arms); - detect_mixed_deref_pat_ctors(tycx, &pat_column)?; - } - let scrut_validity = PlaceValidity::from_bool(tycx.known_valid_scrutinee); let report = compute_match_usefulness( tycx, @@ -1080,48 +1088,3 @@ pub fn analyze_match<'p, 'tcx>( Ok(report) } - -// FIXME(deref_patterns): Currently it's the responsibility of the frontend (rustc or rust-analyzer) -// to ensure that deref patterns don't appear in the same column as normal constructors. Deref -// patterns aren't currently implemented in rust-analyzer, but should they be, the columnwise check -// here could be made generic and shared between frontends. -fn detect_mixed_deref_pat_ctors<'p, 'tcx>( - cx: &RustcPatCtxt<'p, 'tcx>, - column: &PatternColumn<'p, RustcPatCtxt<'p, 'tcx>>, -) -> Result<(), ErrorGuaranteed> { - let Some(&ty) = column.head_ty() else { - return Ok(()); - }; - - // Check for a mix of deref patterns and normal constructors. - let mut normal_ctor_span = None; - let mut deref_pat_span = None; - for pat in column.iter() { - match pat.ctor() { - // The analysis can handle mixing deref patterns with wildcards and opaque patterns. - Wildcard | Opaque(_) => {} - DerefPattern(_) => deref_pat_span = Some(pat.data().span), - // Nothing else can be compared to deref patterns in `Constructor::is_covered_by`. - _ => normal_ctor_span = Some(pat.data().span), - } - } - if let Some(normal_constructor_label) = normal_ctor_span - && let Some(deref_pattern_label) = deref_pat_span - { - return Err(cx.tcx.dcx().emit_err(errors::MixedDerefPatternConstructors { - spans: vec![deref_pattern_label, normal_constructor_label], - smart_pointer_ty: ty.inner(), - deref_pattern_label, - normal_constructor_label, - })); - } - - // Specialize and recurse into the patterns' fields. - let set = column.analyze_ctors(cx, &ty)?; - for ctor in set.present { - for specialized_column in column.specialize(cx, &ty, &ctor).iter() { - detect_mixed_deref_pat_ctors(cx, specialized_column)?; - } - } - Ok(()) -} diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index c348cd508f9..fb94b4afebb 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -720,7 +720,7 @@ use tracing::{debug, instrument}; use self::PlaceValidity::*; use crate::constructor::{Constructor, ConstructorSet, IntRange}; use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat}; -use crate::{MatchArm, PatCx, PrivateUninhabitedField}; +use crate::{MatchArm, PatCx, PrivateUninhabitedField, checks}; #[cfg(not(feature = "rustc"))] pub fn ensure_sufficient_stack(f: impl FnOnce() -> R) -> R { f() @@ -1836,6 +1836,9 @@ pub fn compute_match_usefulness<'p, Cx: PatCx>( scrut_validity: PlaceValidity, complexity_limit: usize, ) -> Result, Cx::Error> { + // The analysis doesn't support deref patterns mixed with normal constructors; error if present. + checks::detect_mixed_deref_pat_ctors(tycx, arms)?; + let mut cx = UsefulnessCtxt { tycx, branch_usefulness: FxHashMap::default(), -- cgit 1.4.1-3-g733a5 From bb643159786c789c0b64f819d36a0979c63f9791 Mon Sep 17 00:00:00 2001 From: dianne Date: Fri, 4 Jul 2025 21:53:03 -0700 Subject: only check for mixed deref/normal constructors when needed --- compiler/rustc_mir_build/src/builder/scope.rs | 1 + compiler/rustc_mir_build/src/thir/pattern/check_match.rs | 1 + compiler/rustc_pattern_analysis/src/lib.rs | 5 +++++ compiler/rustc_pattern_analysis/src/rustc.rs | 16 ++++++++++++++++ compiler/rustc_pattern_analysis/src/usefulness.rs | 4 +++- 5 files changed, 26 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_pattern_analysis/src') diff --git a/compiler/rustc_mir_build/src/builder/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index 405d47c7c79..7fd3050012f 100644 --- a/compiler/rustc_mir_build/src/builder/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -927,6 +927,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scrut_span: rustc_span::Span::default(), refutable: true, known_valid_scrutinee: true, + internal_state: Default::default(), }; let valtree = match self.eval_unevaluated_mir_constant_to_valtree(constant) { diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index b7b160c738d..a49bfc1b8f4 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -406,6 +406,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { scrut_span, refutable, known_valid_scrutinee, + internal_state: Default::default(), } } diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 129fd38725c..66df35f9ee4 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -109,6 +109,11 @@ pub trait PatCx: Sized + fmt::Debug { ) { } + /// Check if we may need to perform additional deref-pattern-specific validation. + fn match_may_contain_deref_pats(&self) -> bool { + true + } + /// The current implementation of deref patterns requires that they can't match on the same /// place as a normal constructor. Since this isn't caught by type-checking, we check it in the /// `PatCx` before running the analysis. This reports an error if the check fails. diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index e9795126db6..ee72b676b38 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -1,3 +1,4 @@ +use std::cell::Cell; use std::fmt; use std::iter::once; @@ -99,6 +100,16 @@ pub struct RustcPatCtxt<'p, 'tcx: 'p> { /// Whether the data at the scrutinee is known to be valid. This is false if the scrutinee comes /// from a union field, a pointer deref, or a reference deref (pending opsem decisions). pub known_valid_scrutinee: bool, + pub internal_state: RustcPatCtxtState, +} + +/// Private fields of [`RustcPatCtxt`], separated out to permit record initialization syntax. +#[derive(Clone, Default)] +pub struct RustcPatCtxtState { + /// Has a deref pattern been lowered? This is initialized to `false` and is updated by + /// [`RustcPatCtxt::lower_pat`] in order to avoid performing deref-pattern-specific validation + /// for everything containing patterns. + has_lowered_deref_pat: Cell, } impl<'p, 'tcx: 'p> fmt::Debug for RustcPatCtxt<'p, 'tcx> { @@ -474,6 +485,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { fields = vec![self.lower_pat(subpattern).at_index(0)]; arity = 1; ctor = DerefPattern(cx.reveal_opaque_ty(subpattern.ty)); + self.internal_state.has_lowered_deref_pat.set(true); } PatKind::Leaf { subpatterns } | PatKind::Variant { subpatterns, .. } => { match ty.kind() { @@ -1028,6 +1040,10 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { } } + fn match_may_contain_deref_pats(&self) -> bool { + self.internal_state.has_lowered_deref_pat.get() + } + fn report_mixed_deref_pat_ctors( &self, deref_pat: &crate::pat::DeconstructedPat, diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index fb94b4afebb..b1c646e9884 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -1837,7 +1837,9 @@ pub fn compute_match_usefulness<'p, Cx: PatCx>( complexity_limit: usize, ) -> Result, Cx::Error> { // The analysis doesn't support deref patterns mixed with normal constructors; error if present. - checks::detect_mixed_deref_pat_ctors(tycx, arms)?; + if tycx.match_may_contain_deref_pats() { + checks::detect_mixed_deref_pat_ctors(tycx, arms)?; + } let mut cx = UsefulnessCtxt { tycx, -- cgit 1.4.1-3-g733a5 From 3567ab19a0edb4f6c7ca88157d84caa3e1564326 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 20 Jul 2025 14:28:58 +0200 Subject: Don't consider unstable fields always-inhabited This reverts the hack in https://github.com/rust-lang/rust/pull/133889 now that `Pin`'s field is no longer public. --- compiler/rustc_middle/src/ty/inhabitedness/mod.rs | 16 -------- compiler/rustc_pattern_analysis/src/rustc.rs | 7 +--- .../uninhabited-unstable-field.current.stderr | 43 ---------------------- .../uninhabited-unstable-field.exhaustive.stderr | 43 ---------------------- tests/ui/uninhabited/uninhabited-unstable-field.rs | 17 +++++---- .../uninhabited/uninhabited-unstable-field.stderr | 40 ++++++++++++++++++++ 6 files changed, 51 insertions(+), 115 deletions(-) delete mode 100644 tests/ui/uninhabited/uninhabited-unstable-field.current.stderr delete mode 100644 tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr create mode 100644 tests/ui/uninhabited/uninhabited-unstable-field.stderr (limited to 'compiler/rustc_pattern_analysis/src') diff --git a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs index 2a336cc21f4..7eb74b52b44 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs @@ -43,7 +43,6 @@ //! This code should only compile in modules where the uninhabitedness of `Foo` //! is visible. -use rustc_span::sym; use rustc_type_ir::TyKind::*; use tracing::instrument; @@ -85,21 +84,6 @@ impl<'tcx> VariantDef { InhabitedPredicate::all( tcx, self.fields.iter().map(|field| { - // Unstable fields are always considered to be inhabited. In the future, - // this could be extended to be conditional on the field being unstable - // only within the module that's querying the inhabitedness, like: - // `let pred = pred.or(InhabitedPredicate::IsUnstable(field.did));` - // but this is unnecessary for now, since it would only affect nightly-only - // code or code within the standard library itself. - // HACK: We filter out `rustc_private` fields since with the flag - // `-Zforce-unstable-if-unmarked` we consider all unmarked fields to be - // unstable when building the compiler. - if tcx - .lookup_stability(field.did) - .is_some_and(|stab| stab.is_unstable() && stab.feature != sym::rustc_private) - { - return InhabitedPredicate::True; - } let pred = tcx.type_of(field.did).instantiate_identity().inhabited_predicate(tcx); if adt.is_enum() { return pred; diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index ee72b676b38..0c1b0d622f2 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -16,7 +16,7 @@ use rustc_middle::ty::{ }; use rustc_middle::{bug, span_bug}; use rustc_session::lint; -use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, sym}; +use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span}; use crate::constructor::Constructor::*; use crate::constructor::{ @@ -238,10 +238,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { let is_visible = adt.is_enum() || field.vis.is_accessible_from(cx.module, cx.tcx); let is_uninhabited = cx.is_uninhabited(*ty); - let is_unstable = cx.tcx.lookup_stability(field.did).is_some_and(|stab| { - stab.is_unstable() && stab.feature != sym::rustc_private - }); - let skip = is_uninhabited && (!is_visible || is_unstable); + let skip = is_uninhabited && !is_visible; (ty, PrivateUninhabitedField(skip)) }); cx.dropless_arena.alloc_from_iter(tys) diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr deleted file mode 100644 index 704475ece48..00000000000 --- a/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `Foo` is non-empty - --> $DIR/uninhabited-unstable-field.rs:15:11 - | -LL | match x {} - | ^ - | -note: `Foo` defined here - --> $DIR/auxiliary/staged-api.rs:5:1 - | -LL | pub struct Foo { - | ^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `Foo` -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: `MyCoroutineState::Complete(_)` not covered - --> $DIR/uninhabited-unstable-field.rs:34:11 - | -LL | match x { - | ^ pattern `MyCoroutineState::Complete(_)` not covered - | -note: `MyCoroutineState` defined here - --> $DIR/auxiliary/staged-api.rs:11:1 - | -LL | pub enum MyCoroutineState { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | Yielded(Y), -LL | Complete(R), - | -------- not covered - = note: the matched value is of type `MyCoroutineState` -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 ~ MyCoroutineState::Yielded(_) => {}, -LL + MyCoroutineState::Complete(_) => todo!() - | - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr deleted file mode 100644 index 704475ece48..00000000000 --- a/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `Foo` is non-empty - --> $DIR/uninhabited-unstable-field.rs:15:11 - | -LL | match x {} - | ^ - | -note: `Foo` defined here - --> $DIR/auxiliary/staged-api.rs:5:1 - | -LL | pub struct Foo { - | ^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `Foo` -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: `MyCoroutineState::Complete(_)` not covered - --> $DIR/uninhabited-unstable-field.rs:34:11 - | -LL | match x { - | ^ pattern `MyCoroutineState::Complete(_)` not covered - | -note: `MyCoroutineState` defined here - --> $DIR/auxiliary/staged-api.rs:11:1 - | -LL | pub enum MyCoroutineState { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | Yielded(Y), -LL | Complete(R), - | -------- not covered - = note: the matched value is of type `MyCoroutineState` -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 ~ MyCoroutineState::Yielded(_) => {}, -LL + MyCoroutineState::Complete(_) => todo!() - | - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.rs b/tests/ui/uninhabited/uninhabited-unstable-field.rs index 44527319ffd..321b864aa27 100644 --- a/tests/ui/uninhabited/uninhabited-unstable-field.rs +++ b/tests/ui/uninhabited/uninhabited-unstable-field.rs @@ -1,6 +1,9 @@ //@ aux-build: staged-api.rs -//@ revisions: current exhaustive -#![cfg_attr(exhaustive, feature(exhaustive_patterns))] +//! The field of `Pin` used to be public, which would cause `Pin` to be uninhabited. To remedy +//! this, we temporarily made it so unstable fields are always considered inhabited. This has now +//! been reverted, and this file ensures that we don't special-case unstable fields wrt +//! inhabitedness anymore. +#![feature(exhaustive_patterns)] #![feature(never_type)] #![feature(my_coro_state)] // Custom feature from `staged-api.rs` #![deny(unreachable_patterns)] @@ -13,31 +16,29 @@ enum Void {} fn demo(x: Foo) { match x {} - //~^ ERROR non-exhaustive patterns } -// Ensure that the pattern is not considered unreachable. +// Ensure that the pattern is considered unreachable. fn demo2(x: Foo) { match x { - Foo { .. } => {} + Foo { .. } => {} //~ ERROR unreachable } } // Same as above, but for wildcard. fn demo3(x: Foo) { match x { - _ => {} + _ => {} //~ ERROR unreachable } } fn unstable_enum(x: MyCoroutineState) { match x { - //~^ ERROR non-exhaustive patterns MyCoroutineState::Yielded(_) => {} } match x { MyCoroutineState::Yielded(_) => {} - MyCoroutineState::Complete(_) => {} + MyCoroutineState::Complete(_) => {} //~ ERROR unreachable } } diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.stderr new file mode 100644 index 00000000000..a0c9f9366a6 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-unstable-field.stderr @@ -0,0 +1,40 @@ +error: unreachable pattern + --> $DIR/uninhabited-unstable-field.rs:24:9 + | +LL | Foo { .. } => {} + | ^^^^^^^^^^------ + | | + | matches no values because `Foo` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types +note: the lint level is defined here + --> $DIR/uninhabited-unstable-field.rs:9:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/uninhabited-unstable-field.rs:31:9 + | +LL | _ => {} + | ^------ + | | + | matches no values because `Foo` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types + +error: unreachable pattern + --> $DIR/uninhabited-unstable-field.rs:41:9 + | +LL | MyCoroutineState::Complete(_) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types + +error: aborting due to 3 previous errors + -- cgit 1.4.1-3-g733a5