|
1 | 1 | use std::fmt;
|
2 | 2 |
|
3 | 3 | use rustc_data_structures::intern::Interned;
|
4 |
| -use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
5 |
| -use rustc_type_ir::Flags; |
| 4 | +use rustc_macros::HashStable; |
| 5 | +use rustc_type_ir::ir_print::IrPrint; |
| 6 | +use rustc_type_ir::{ |
| 7 | + Flags, {self as ir}, |
| 8 | +}; |
6 | 9 |
|
| 10 | +use super::TyCtxt; |
7 | 11 | use super::flags::FlagComputation;
|
8 | 12 | use crate::ty;
|
9 | 13 |
|
| 14 | +pub type PatternKind<'tcx> = ir::PatternKind<TyCtxt<'tcx>>; |
| 15 | + |
10 | 16 | #[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
|
11 | 17 | #[rustc_pass_by_value]
|
12 | 18 | pub struct Pattern<'tcx>(pub Interned<'tcx, PatternKind<'tcx>>);
|
@@ -44,9 +50,9 @@ impl<'tcx> fmt::Debug for Pattern<'tcx> {
|
44 | 50 | }
|
45 | 51 | }
|
46 | 52 |
|
47 |
| -impl<'tcx> fmt::Debug for PatternKind<'tcx> { |
48 |
| - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
49 |
| - match *self { |
| 53 | +impl<'tcx> IrPrint<PatternKind<'tcx>> for TyCtxt<'tcx> { |
| 54 | + fn print(t: &PatternKind<'tcx>, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 55 | + match *t { |
50 | 56 | PatternKind::Range { start, end } => {
|
51 | 57 | write!(f, "{start}")?;
|
52 | 58 |
|
@@ -74,10 +80,15 @@ impl<'tcx> fmt::Debug for PatternKind<'tcx> {
|
74 | 80 | }
|
75 | 81 | }
|
76 | 82 | }
|
| 83 | + |
| 84 | + fn print_debug(t: &PatternKind<'tcx>, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 85 | + Self::print(t, fmt) |
| 86 | + } |
77 | 87 | }
|
78 | 88 |
|
79 |
| -#[derive(Clone, PartialEq, Eq, Hash)] |
80 |
| -#[derive(HashStable, TyEncodable, TyDecodable, TypeVisitable, TypeFoldable)] |
81 |
| -pub enum PatternKind<'tcx> { |
82 |
| - Range { start: ty::Const<'tcx>, end: ty::Const<'tcx> }, |
| 89 | +impl<'tcx> rustc_type_ir::inherent::IntoKind for Pattern<'tcx> { |
| 90 | + type Kind = PatternKind<'tcx>; |
| 91 | + fn kind(self) -> Self::Kind { |
| 92 | + *self |
| 93 | + } |
83 | 94 | }
|
0 commit comments