Skip to content

Commit e417992

Browse files
committed
Add static assertions for some unreachble paths
1 parent 461c0cc commit e417992

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ pub(super) struct Slice {
278278

279279
impl Slice {
280280
fn arity(self) -> usize {
281-
unimplemented!()
281+
match self._unimplemented {}
282282
}
283283

284284
/// See `Constructor::is_covered_by`
285285
fn is_covered_by(self, _other: Self) -> bool {
286-
unimplemented!() // never called as Slice contains Void
286+
match self._unimplemented {}
287287
}
288288
}
289289

@@ -442,7 +442,7 @@ impl Constructor {
442442
split_range.split(int_ranges.cloned());
443443
split_range.iter().map(IntRange).collect()
444444
}
445-
Slice(_) => unimplemented!(),
445+
Slice(slice) => match slice._unimplemented {},
446446
// Any other constructor can be used unchanged.
447447
_ => smallvec![self.clone()],
448448
}
@@ -465,12 +465,8 @@ impl Constructor {
465465
(Variant(self_id), Variant(other_id)) => self_id == other_id,
466466

467467
(IntRange(self_range), IntRange(other_range)) => self_range.is_covered_by(other_range),
468-
(FloatRange(..), FloatRange(..)) => {
469-
unimplemented!()
470-
}
471-
(Str(..), Str(..)) => {
472-
unimplemented!()
473-
}
468+
(FloatRange(void), FloatRange(..)) => match *void {},
469+
(Str(void), Str(..)) => match *void {},
474470
(Slice(self_slice), Slice(other_slice)) => self_slice.is_covered_by(*other_slice),
475471

476472
// We are trying to inspect an opaque constant. Thus we skip the row.
@@ -817,9 +813,7 @@ impl<'p> Fields<'p> {
817813
Fields::wildcards_from_tys(cx, once(ty.clone()))
818814
}
819815
},
820-
Slice(..) => {
821-
unimplemented!()
822-
}
816+
Slice(slice) => match slice._unimplemented {},
823817
Str(..)
824818
| FloatRange(..)
825819
| IntRange(..)
@@ -1023,9 +1017,9 @@ impl<'p> DeconstructedPat<'p> {
10231017
PatKind::Wild
10241018
}
10251019
},
1026-
&Slice(Slice { _unimplemented: _void }) => unimplemented!(),
1027-
&Str(_void) => unimplemented!(),
1028-
&FloatRange(_void) => unimplemented!(),
1020+
&Slice(slice) => match slice._unimplemented {},
1021+
&Str(void) => match void {},
1022+
&FloatRange(void) => match void {},
10291023
IntRange(range) => return range.to_pat(cx, self.ty.clone()),
10301024
Wildcard | NonExhaustive => PatKind::Wild,
10311025
Missing { .. } => {
@@ -1074,7 +1068,7 @@ impl<'p> DeconstructedPat<'p> {
10741068
(Slice(self_slice), Slice(other_slice))
10751069
if self_slice.arity() != other_slice.arity() =>
10761070
{
1077-
unimplemented!()
1071+
match self_slice._unimplemented {}
10781072
}
10791073
_ => self.fields.iter_patterns().collect(),
10801074
}

0 commit comments

Comments
 (0)