Skip to content

Commit ec1483b

Browse files
committed
Remove PatKind::Slice
1 parent 2b6f438 commit ec1483b

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -897,10 +897,12 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
897897
}
898898
}
899899

900-
let prefix = prefix.iter().map(hoist).collect();
901-
let suffix = suffix.iter().map(hoist).collect();
900+
let prefix = prefix.iter().map(hoist).collect::<Vec<_>>();
901+
let suffix = suffix.iter().map(hoist).collect::<Vec<_>>();
902902

903-
PatKind::Slice { prefix, has_dot_dot, suffix }
903+
let mut s = String::new();
904+
print::write_slice_like(&mut s, &prefix, has_dot_dot, &suffix).unwrap();
905+
PatKind::Print(s)
904906
}
905907
Never if self.tcx.features().never_patterns => PatKind::Never,
906908
Never | Wildcard | NonExhaustive | Hidden | PrivateUninhabited => {

compiler/rustc_pattern_analysis/src/rustc/print.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,11 @@ pub(crate) struct FieldPat<'tcx> {
2727
pub(crate) struct Pat<'tcx> {
2828
#[allow(dead_code)]
2929
pub(crate) ty: Ty<'tcx>,
30-
pub(crate) kind: PatKind<'tcx>,
30+
pub(crate) kind: PatKind,
3131
}
3232

3333
#[derive(Clone, Debug)]
34-
pub(crate) enum PatKind<'tcx> {
35-
Slice {
36-
prefix: Box<[Box<Pat<'tcx>>]>,
37-
/// True if this slice-like pattern should include a `..` between the
38-
/// prefix and suffix.
39-
has_dot_dot: bool,
40-
suffix: Box<[Box<Pat<'tcx>>]>,
41-
},
42-
34+
pub(crate) enum PatKind {
4335
Never,
4436

4537
Print(String),
@@ -49,9 +41,6 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
4941
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5042
match self.kind {
5143
PatKind::Never => write!(f, "!"),
52-
PatKind::Slice { ref prefix, has_dot_dot, ref suffix } => {
53-
write_slice_like(f, prefix, has_dot_dot, suffix)
54-
}
5544
PatKind::Print(ref string) => write!(f, "{string}"),
5645
}
5746
}
@@ -173,7 +162,7 @@ pub(crate) fn write_ref_like<'tcx>(
173162
write!(f, "{subpattern}")
174163
}
175164

176-
fn write_slice_like<'tcx>(
165+
pub(crate) fn write_slice_like<'tcx>(
177166
f: &mut impl fmt::Write,
178167
prefix: &[Box<Pat<'tcx>>],
179168
has_dot_dot: bool,

0 commit comments

Comments
 (0)