Skip to content

Commit 432556f

Browse files
committed
Move FlagComputation to rustc_type_ir
1 parent 7cd6e2f commit 432556f

File tree

3 files changed

+386
-1
lines changed

3 files changed

+386
-1
lines changed

compiler/rustc_middle/src/ty/pattern.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,34 @@ use std::fmt;
22

33
use rustc_data_structures::intern::Interned;
44
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
5+
use rustc_type_ir::Flags;
56

7+
use super::flags::FlagComputation;
68
use crate::ty;
79

810
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
911
#[rustc_pass_by_value]
1012
pub struct Pattern<'tcx>(pub Interned<'tcx, PatternKind<'tcx>>);
1113

14+
impl<'tcx> Flags for Pattern<'tcx> {
15+
fn flags(&self) -> rustc_type_ir::TypeFlags {
16+
match &**self {
17+
ty::PatternKind::Range { start, end } => {
18+
FlagComputation::for_const_kind(&start.kind()).flags
19+
| FlagComputation::for_const_kind(&end.kind()).flags
20+
}
21+
}
22+
}
23+
24+
fn outer_exclusive_binder(&self) -> rustc_type_ir::DebruijnIndex {
25+
match &**self {
26+
ty::PatternKind::Range { start, end } => {
27+
start.outer_exclusive_binder().max(end.outer_exclusive_binder())
28+
}
29+
}
30+
}
31+
}
32+
1233
impl<'tcx> std::ops::Deref for Pattern<'tcx> {
1334
type Target = PatternKind<'tcx>;
1435

0 commit comments

Comments
 (0)