1
Fork 0

Auto merge of #96892 - oli-obk:🐌_obligation_cause_code_🐌, r=estebank

Clean up derived obligation creation

r? `@estebank`

working on fixing the perf regression from https://github.com/rust-lang/rust/pull/91030#issuecomment-1083360210
This commit is contained in:
bors 2022-05-17 01:46:25 +00:00
commit c1d65eaa45
11 changed files with 176 additions and 219 deletions

View file

@ -69,7 +69,7 @@ impl<'tcx> PredicateObligation<'tcx> {
}
}
impl TraitObligation<'_> {
impl<'tcx> TraitObligation<'tcx> {
/// Returns `true` if the trait predicate is considered `const` in its ParamEnv.
pub fn is_const(&self) -> bool {
match (self.predicate.skip_binder().constness, self.param_env.constness()) {
@ -77,6 +77,13 @@ impl TraitObligation<'_> {
_ => false,
}
}
pub fn derived_cause(
&self,
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
) -> ObligationCause<'tcx> {
self.cause.clone().derived_cause(self.predicate, variant)
}
}
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.