1
Fork 0

Intermediate formatting and such

This commit is contained in:
Jack Huey 2020-12-23 13:16:25 -05:00
parent 8278314a8b
commit 4cb3d6f983
7 changed files with 63 additions and 74 deletions

View file

@ -205,13 +205,8 @@ impl FlagComputation {
}
fn add_predicate_kind(&mut self, kind: ty::PredicateKind<'_>) {
match kind {
ty::PredicateKind::ForAll(binder) => {
self.bound_computation(binder, |computation, atom| {
computation.add_predicate_atom(atom)
});
}
}
let ty::PredicateKind::ForAll(binder) = kind;
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
}
fn add_predicate_atom(&mut self, atom: ty::PredicateAtom<'_>) {

View file

@ -1072,9 +1072,8 @@ impl<'tcx> Predicate<'tcx> {
///
/// Note that this method panics in case this predicate has unbound variables.
pub fn skip_binders(self) -> PredicateAtom<'tcx> {
match self.kind() {
&PredicateKind::ForAll(binder) => binder.skip_binder(),
}
let &PredicateKind::ForAll(binder) = self.kind();
binder.skip_binder()
}
/// Returns the inner `PredicateAtom`.
@ -1084,25 +1083,22 @@ impl<'tcx> Predicate<'tcx> {
/// Rebinding the returned atom can causes the previously bound variables
/// to end up at the wrong binding level.
pub fn skip_binders_unchecked(self) -> PredicateAtom<'tcx> {
match self.kind() {
&PredicateKind::ForAll(binder) => binder.skip_binder(),
}
let &PredicateKind::ForAll(binder) = self.kind();
binder.skip_binder()
}
/// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an
/// `Atom`, then it is not allowed to contain escaping bound vars.
pub fn bound_atom(self) -> Binder<PredicateAtom<'tcx>> {
match self.kind() {
&PredicateKind::ForAll(binder) => binder,
}
let &PredicateKind::ForAll(binder) = self.kind();
binder
}
/// Allows using a `Binder<PredicateAtom<'tcx>>` even if the given predicate previously
/// contained unbound variables by shifting these variables outwards.
pub fn bound_atom_with_opt_escaping(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {
match self.kind() {
&PredicateKind::ForAll(binder) => binder,
}
let &PredicateKind::ForAll(binder) = self.kind();
binder
}
}

View file

@ -2068,9 +2068,8 @@ define_print_and_forward_display! {
}
ty::Predicate<'tcx> {
match self.kind() {
ty::PredicateKind::ForAll(binder) => p!(print(binder)),
}
let ty::PredicateKind::ForAll(binder) = self.kind();
p!(print(binder))
}
ty::PredicateAtom<'tcx> {

View file

@ -1034,12 +1034,12 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Region<'tcx> {
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
let new = ty::PredicateKind::super_fold_with(self.inner.kind, folder);
let new = self.inner.kind.super_fold_with(folder);
folder.tcx().reuse_or_mk_predicate(self, new)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
ty::PredicateKind::super_visit_with(&self.inner.kind, visitor)
self.inner.kind.super_visit_with(visitor)
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {