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