Remove PatKind::Ref
This commit is contained in:
parent
15cc0e1b5c
commit
283243ac5a
@ -865,7 +865,11 @@ fn hoist_witness_pat(&self, pat: &WitnessPat<'p, 'tcx>) -> print::Pat<'tcx> {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
PatKind::Print(s)
|
PatKind::Print(s)
|
||||||
}
|
}
|
||||||
Ref => PatKind::Deref { subpattern: hoist(&pat.fields[0]) },
|
Ref => {
|
||||||
|
let mut s = String::new();
|
||||||
|
print::write_ref_like(&mut s, pat.ty().inner(), &hoist(&pat.fields[0])).unwrap();
|
||||||
|
PatKind::Print(s)
|
||||||
|
}
|
||||||
Slice(slice) => {
|
Slice(slice) => {
|
||||||
let (prefix_len, has_dot_dot) = match slice.kind {
|
let (prefix_len, has_dot_dot) = match slice.kind {
|
||||||
SliceKind::FixedLen(len) => (len, false),
|
SliceKind::FixedLen(len) => (len, false),
|
||||||
|
@ -26,16 +26,13 @@ pub(crate) struct FieldPat<'tcx> {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct Pat<'tcx> {
|
pub(crate) struct Pat<'tcx> {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) ty: Ty<'tcx>,
|
pub(crate) ty: Ty<'tcx>,
|
||||||
pub(crate) kind: PatKind<'tcx>,
|
pub(crate) kind: PatKind<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum PatKind<'tcx> {
|
pub(crate) enum PatKind<'tcx> {
|
||||||
Deref {
|
|
||||||
subpattern: Box<Pat<'tcx>>,
|
|
||||||
},
|
|
||||||
|
|
||||||
Constant {
|
Constant {
|
||||||
value: mir::Const<'tcx>,
|
value: mir::Const<'tcx>,
|
||||||
},
|
},
|
||||||
@ -59,7 +56,6 @@ 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::Never => write!(f, "!"),
|
PatKind::Never => write!(f, "!"),
|
||||||
PatKind::Deref { ref subpattern } => write_ref_like(f, self.ty, subpattern),
|
|
||||||
PatKind::Constant { value } => write!(f, "{value}"),
|
PatKind::Constant { value } => write!(f, "{value}"),
|
||||||
PatKind::Range(ref range) => write!(f, "{range}"),
|
PatKind::Range(ref range) => write!(f, "{range}"),
|
||||||
PatKind::Slice { ref prefix, has_dot_dot, ref suffix } => {
|
PatKind::Slice { ref prefix, has_dot_dot, ref suffix } => {
|
||||||
@ -172,7 +168,7 @@ pub(crate) fn write_struct_like<'tcx>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_ref_like<'tcx>(
|
pub(crate) fn write_ref_like<'tcx>(
|
||||||
f: &mut impl fmt::Write,
|
f: &mut impl fmt::Write,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
subpattern: &Pat<'tcx>,
|
subpattern: &Pat<'tcx>,
|
||||||
|
Loading…
Reference in New Issue
Block a user