Skip to content

Commit 283243a

Browse files
committed
Remove PatKind::Ref
1 parent 15cc0e1 commit 283243a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,11 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
865865
.unwrap();
866866
PatKind::Print(s)
867867
}
868-
Ref => PatKind::Deref { subpattern: hoist(&pat.fields[0]) },
868+
Ref => {
869+
let mut s = String::new();
870+
print::write_ref_like(&mut s, pat.ty().inner(), &hoist(&pat.fields[0])).unwrap();
871+
PatKind::Print(s)
872+
}
869873
Slice(slice) => {
870874
let (prefix_len, has_dot_dot) = match slice.kind {
871875
SliceKind::FixedLen(len) => (len, false),

compiler/rustc_pattern_analysis/src/rustc/print.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ pub(crate) struct FieldPat<'tcx> {
2626

2727
#[derive(Clone, Debug)]
2828
pub(crate) struct Pat<'tcx> {
29+
#[allow(dead_code)]
2930
pub(crate) ty: Ty<'tcx>,
3031
pub(crate) kind: PatKind<'tcx>,
3132
}
3233

3334
#[derive(Clone, Debug)]
3435
pub(crate) enum PatKind<'tcx> {
35-
Deref {
36-
subpattern: Box<Pat<'tcx>>,
37-
},
38-
3936
Constant {
4037
value: mir::Const<'tcx>,
4138
},
@@ -59,7 +56,6 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
5956
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6057
match self.kind {
6158
PatKind::Never => write!(f, "!"),
62-
PatKind::Deref { ref subpattern } => write_ref_like(f, self.ty, subpattern),
6359
PatKind::Constant { value } => write!(f, "{value}"),
6460
PatKind::Range(ref range) => write!(f, "{range}"),
6561
PatKind::Slice { ref prefix, has_dot_dot, ref suffix } => {
@@ -172,7 +168,7 @@ pub(crate) fn write_struct_like<'tcx>(
172168
Ok(())
173169
}
174170

175-
fn write_ref_like<'tcx>(
171+
pub(crate) fn write_ref_like<'tcx>(
176172
f: &mut impl fmt::Write,
177173
ty: Ty<'tcx>,
178174
subpattern: &Pat<'tcx>,

0 commit comments

Comments
 (0)