Move an extension trait method onto the type directly and reuse it
This commit is contained in:
parent
7e2e3d4ebe
commit
704bbe5210
5 changed files with 36 additions and 46 deletions
|
@ -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: fn(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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue