Add to_constraint_category to ObligationCause and SubregionOrigin

This commit is contained in:
Jack Huey
2022-09-16 17:00:11 -04:00
parent 6075877c89
commit 67653292be
4 changed files with 24 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ mod structural_impls;
pub mod util;
use crate::infer::canonical::Canonical;
use crate::mir::ConstraintCategory;
use crate::ty::abstract_const::NotConstEvaluatable;
use crate::ty::subst::SubstsRef;
use crate::ty::{self, AdtKind, Ty, TyCtxt};
@@ -183,6 +184,13 @@ impl<'tcx> ObligationCause<'tcx> {
variant(DerivedObligationCause { parent_trait_pred, parent_code: self.code }).into();
self
}
pub fn to_constraint_category(&self) -> ConstraintCategory<'tcx> {
match self.code() {
MatchImpl(cause, _) => cause.to_constraint_category(),
_ => ConstraintCategory::BoringNoLocation,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Lift)]