Intermediate formatting and such
This commit is contained in:
parent
8278314a8b
commit
4cb3d6f983
@ -205,13 +205,8 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_predicate_kind(&mut self, kind: ty::PredicateKind<'_>) {
|
fn add_predicate_kind(&mut self, kind: ty::PredicateKind<'_>) {
|
||||||
match kind {
|
let ty::PredicateKind::ForAll(binder) = kind;
|
||||||
ty::PredicateKind::ForAll(binder) => {
|
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
|
||||||
self.bound_computation(binder, |computation, atom| {
|
|
||||||
computation.add_predicate_atom(atom)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_predicate_atom(&mut self, atom: ty::PredicateAtom<'_>) {
|
fn add_predicate_atom(&mut self, atom: ty::PredicateAtom<'_>) {
|
||||||
|
@ -1072,9 +1072,8 @@ pub fn kind(self) -> &'tcx PredicateKind<'tcx> {
|
|||||||
///
|
///
|
||||||
/// Note that this method panics in case this predicate has unbound variables.
|
/// Note that this method panics in case this predicate has unbound variables.
|
||||||
pub fn skip_binders(self) -> PredicateAtom<'tcx> {
|
pub fn skip_binders(self) -> PredicateAtom<'tcx> {
|
||||||
match self.kind() {
|
let &PredicateKind::ForAll(binder) = self.kind();
|
||||||
&PredicateKind::ForAll(binder) => binder.skip_binder(),
|
binder.skip_binder()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the inner `PredicateAtom`.
|
/// Returns the inner `PredicateAtom`.
|
||||||
@ -1084,25 +1083,22 @@ pub fn skip_binders(self) -> PredicateAtom<'tcx> {
|
|||||||
/// Rebinding the returned atom can causes the previously bound variables
|
/// Rebinding the returned atom can causes the previously bound variables
|
||||||
/// to end up at the wrong binding level.
|
/// to end up at the wrong binding level.
|
||||||
pub fn skip_binders_unchecked(self) -> PredicateAtom<'tcx> {
|
pub fn skip_binders_unchecked(self) -> PredicateAtom<'tcx> {
|
||||||
match self.kind() {
|
let &PredicateKind::ForAll(binder) = self.kind();
|
||||||
&PredicateKind::ForAll(binder) => binder.skip_binder(),
|
binder.skip_binder()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an
|
/// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an
|
||||||
/// `Atom`, then it is not allowed to contain escaping bound vars.
|
/// `Atom`, then it is not allowed to contain escaping bound vars.
|
||||||
pub fn bound_atom(self) -> Binder<PredicateAtom<'tcx>> {
|
pub fn bound_atom(self) -> Binder<PredicateAtom<'tcx>> {
|
||||||
match self.kind() {
|
let &PredicateKind::ForAll(binder) = self.kind();
|
||||||
&PredicateKind::ForAll(binder) => binder,
|
binder
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows using a `Binder<PredicateAtom<'tcx>>` even if the given predicate previously
|
/// Allows using a `Binder<PredicateAtom<'tcx>>` even if the given predicate previously
|
||||||
/// contained unbound variables by shifting these variables outwards.
|
/// contained unbound variables by shifting these variables outwards.
|
||||||
pub fn bound_atom_with_opt_escaping(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {
|
pub fn bound_atom_with_opt_escaping(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {
|
||||||
match self.kind() {
|
let &PredicateKind::ForAll(binder) = self.kind();
|
||||||
&PredicateKind::ForAll(binder) => binder,
|
binder
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2068,9 +2068,8 @@ pub fn print_only_trait_path(self) -> ty::Binder<TraitRefPrintOnlyTraitPath<'tcx
|
|||||||
}
|
}
|
||||||
|
|
||||||
ty::Predicate<'tcx> {
|
ty::Predicate<'tcx> {
|
||||||
match self.kind() {
|
let ty::PredicateKind::ForAll(binder) = self.kind();
|
||||||
ty::PredicateKind::ForAll(binder) => p!(print(binder)),
|
p!(print(binder))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateAtom<'tcx> {
|
ty::PredicateAtom<'tcx> {
|
||||||
|
@ -1034,12 +1034,12 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::Br
|
|||||||
|
|
||||||
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
|
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
|
||||||
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
|
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)
|
folder.tcx().reuse_or_mk_predicate(self, new)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
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> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||||
|
@ -345,8 +345,8 @@ fn progress_changed_obligations(
|
|||||||
|
|
||||||
let infcx = self.selcx.infcx();
|
let infcx = self.selcx.infcx();
|
||||||
|
|
||||||
match *obligation.predicate.kind() {
|
let ty::PredicateKind::ForAll(binder) = *obligation.predicate.kind();
|
||||||
ty::PredicateKind::ForAll(binder) if binder.skip_binder().has_escaping_bound_vars() => {
|
if binder.skip_binder().has_escaping_bound_vars() {
|
||||||
match binder.skip_binder() {
|
match binder.skip_binder() {
|
||||||
// Evaluation will discard candidates using the leak check.
|
// Evaluation will discard candidates using the leak check.
|
||||||
// This means we need to pass it the bound version of our
|
// This means we need to pass it the bound version of our
|
||||||
@ -385,8 +385,8 @@ fn progress_changed_obligations(
|
|||||||
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
ty::PredicateKind::ForAll(binder) => match binder.skip_binder() {
|
match binder.skip_binder() {
|
||||||
ty::PredicateAtom::Trait(data, _) => {
|
ty::PredicateAtom::Trait(data, _) => {
|
||||||
let trait_obligation = obligation.with(Binder::dummy(data));
|
let trait_obligation = obligation.with(Binder::dummy(data));
|
||||||
|
|
||||||
@ -598,7 +598,7 @@ fn progress_changed_obligations(
|
|||||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||||
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,13 +94,11 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||||||
// region relationships.
|
// region relationships.
|
||||||
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
|
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
|
||||||
assert!(!obligation.has_escaping_bound_vars());
|
assert!(!obligation.has_escaping_bound_vars());
|
||||||
match obligation.predicate.kind() {
|
let ty::PredicateKind::ForAll(binder) = obligation.predicate.kind();
|
||||||
&ty::PredicateKind::ForAll(binder)
|
if binder.skip_binder().has_escaping_bound_vars() {
|
||||||
if binder.skip_binder().has_escaping_bound_vars() =>
|
|
||||||
{
|
|
||||||
vec![]
|
vec![]
|
||||||
}
|
} else {
|
||||||
&ty::PredicateKind::ForAll(binder) => match binder.skip_binder() {
|
match binder.skip_binder() {
|
||||||
ty::PredicateAtom::Trait(..)
|
ty::PredicateAtom::Trait(..)
|
||||||
| ty::PredicateAtom::Subtype(..)
|
| ty::PredicateAtom::Subtype(..)
|
||||||
| ty::PredicateAtom::Projection(..)
|
| ty::PredicateAtom::Projection(..)
|
||||||
@ -124,7 +122,7 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||||||
tcx.push_outlives_components(ty_a, &mut components);
|
tcx.push_outlives_components(ty_a, &mut components);
|
||||||
implied_bounds_from_components(r_b, components)
|
implied_bounds_from_components(r_b, components)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,13 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
|
|||||||
if tcx.has_attr(item_def_id, sym::rustc_outlives) {
|
if tcx.has_attr(item_def_id, sym::rustc_outlives) {
|
||||||
let mut pred: Vec<String> = predicates
|
let mut pred: Vec<String> = predicates
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(out_pred, _)| match out_pred.kind() {
|
.map(|(out_pred, _)| {
|
||||||
ty::PredicateKind::ForAll(binder) => match binder.skip_binder() {
|
let ty::PredicateKind::ForAll(binder) = out_pred.kind();
|
||||||
|
match binder.skip_binder() {
|
||||||
ty::PredicateAtom::RegionOutlives(p) => p.to_string(),
|
ty::PredicateAtom::RegionOutlives(p) => p.to_string(),
|
||||||
ty::PredicateAtom::TypeOutlives(p) => p.to_string(),
|
ty::PredicateAtom::TypeOutlives(p) => p.to_string(),
|
||||||
err => bug!("unexpected predicate {:?}", err),
|
err => bug!("unexpected predicate {:?}", err),
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
pred.sort();
|
pred.sort();
|
||||||
|
Loading…
Reference in New Issue
Block a user