Skip to content

Commit 9952e4d

Browse files
committed
Remove PatKind::Constant
1 parent 283243a commit 9952e4d

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
784784
} else if range.is_singleton() {
785785
let lo = cx.hoist_pat_range_bdy(range.lo, ty);
786786
let value = lo.as_finite().unwrap();
787-
PatKind::Constant { value }
787+
PatKind::Print(value.to_string())
788788
} else {
789789
// We convert to an inclusive range for diagnostics.
790790
let mut end = rustc_hir::RangeEnd::Included;
@@ -827,7 +827,8 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
827827
let cx = self;
828828
let hoist = |p| Box::new(cx.hoist_witness_pat(p));
829829
let kind = match pat.ctor() {
830-
Bool(b) => PatKind::Constant { value: mir::Const::from_bool(cx.tcx, *b) },
830+
Bool(b) => PatKind::Print(b.to_string()),
831+
Str(s) => PatKind::Print(s.to_string()),
831832
IntRange(range) => return self.hoist_pat_range(range, *pat.ty()),
832833
Struct if pat.ty().is_box() => {
833834
// Outside of the `alloc` crate, the only way to create a struct pattern
@@ -901,7 +902,6 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
901902

902903
PatKind::Slice { prefix, has_dot_dot, suffix }
903904
}
904-
&Str(value) => PatKind::Constant { value },
905905
Never if self.tcx.features().never_patterns => PatKind::Never,
906906
Never | Wildcard | NonExhaustive | Hidden | PrivateUninhabited => {
907907
PatKind::Print("_".to_string())

compiler/rustc_pattern_analysis/src/rustc/print.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
1212
use std::fmt;
1313

14+
use rustc_middle::bug;
1415
use rustc_middle::thir::PatRange;
1516
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
16-
use rustc_middle::{bug, mir};
1717
use rustc_span::sym;
1818
use rustc_target::abi::{FieldIdx, VariantIdx};
1919

@@ -33,10 +33,6 @@ pub(crate) struct Pat<'tcx> {
3333

3434
#[derive(Clone, Debug)]
3535
pub(crate) enum PatKind<'tcx> {
36-
Constant {
37-
value: mir::Const<'tcx>,
38-
},
39-
4036
Range(Box<PatRange<'tcx>>),
4137

4238
Slice {
@@ -56,7 +52,6 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
5652
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5753
match self.kind {
5854
PatKind::Never => write!(f, "!"),
59-
PatKind::Constant { value } => write!(f, "{value}"),
6055
PatKind::Range(ref range) => write!(f, "{range}"),
6156
PatKind::Slice { ref prefix, has_dot_dot, ref suffix } => {
6257
write_slice_like(f, prefix, has_dot_dot, suffix)

0 commit comments

Comments
 (0)