Remove PatKind::Wild
This commit is contained in:
parent
f53eb2724d
commit
92eb159d04
2 changed files with 4 additions and 5 deletions
|
@ -780,7 +780,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
|
||||||
use MaybeInfiniteInt::*;
|
use MaybeInfiniteInt::*;
|
||||||
let cx = self;
|
let cx = self;
|
||||||
let kind = if matches!((range.lo, range.hi), (NegInfinity, PosInfinity)) {
|
let kind = if matches!((range.lo, range.hi), (NegInfinity, PosInfinity)) {
|
||||||
PatKind::Wild
|
PatKind::Print("_".to_string())
|
||||||
} else if range.is_singleton() {
|
} else if range.is_singleton() {
|
||||||
let lo = cx.hoist_pat_range_bdy(range.lo, ty);
|
let lo = cx.hoist_pat_range_bdy(range.lo, ty);
|
||||||
let value = lo.as_finite().unwrap();
|
let value = lo.as_finite().unwrap();
|
||||||
|
@ -890,7 +890,9 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
|
||||||
}
|
}
|
||||||
&Str(value) => PatKind::Constant { value },
|
&Str(value) => PatKind::Constant { value },
|
||||||
Never if self.tcx.features().never_patterns => PatKind::Never,
|
Never if self.tcx.features().never_patterns => PatKind::Never,
|
||||||
Never | Wildcard | NonExhaustive | Hidden | PrivateUninhabited => PatKind::Wild,
|
Never | Wildcard | NonExhaustive | Hidden | PrivateUninhabited => {
|
||||||
|
PatKind::Print("_".to_string())
|
||||||
|
}
|
||||||
Missing { .. } => bug!(
|
Missing { .. } => bug!(
|
||||||
"trying to convert a `Missing` constructor into a `Pat`; this is probably a bug,
|
"trying to convert a `Missing` constructor into a `Pat`; this is probably a bug,
|
||||||
`Missing` should have been processed in `apply_constructors`"
|
`Missing` should have been processed in `apply_constructors`"
|
||||||
|
|
|
@ -32,8 +32,6 @@ pub(crate) struct Pat<'tcx> {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum PatKind<'tcx> {
|
pub(crate) enum PatKind<'tcx> {
|
||||||
Wild,
|
|
||||||
|
|
||||||
StructLike {
|
StructLike {
|
||||||
enum_info: EnumInfo<'tcx>,
|
enum_info: EnumInfo<'tcx>,
|
||||||
subpatterns: Vec<FieldPat<'tcx>>,
|
subpatterns: Vec<FieldPat<'tcx>>,
|
||||||
|
@ -69,7 +67,6 @@ pub(crate) enum PatKind<'tcx> {
|
||||||
impl<'tcx> fmt::Display for Pat<'tcx> {
|
impl<'tcx> fmt::Display for Pat<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
PatKind::Wild => write!(f, "_"),
|
|
||||||
PatKind::Never => write!(f, "!"),
|
PatKind::Never => write!(f, "!"),
|
||||||
PatKind::Box { ref subpattern } => write!(f, "box {subpattern}"),
|
PatKind::Box { ref subpattern } => write!(f, "box {subpattern}"),
|
||||||
PatKind::StructLike { ref enum_info, ref subpatterns } => {
|
PatKind::StructLike { ref enum_info, ref subpatterns } => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue