Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2801f9a

Browse files
committed
Auto merge of #142746 - compiler-errors:super-implied-outlives, r=lcnr
Apply `impl_super_outlives` optimization to new trait solver I never did #128746 for the new solver. r? lcnr
2 parents a17780d + 24ea06c commit 2801f9a

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

‎compiler/rustc_middle/src/ty/context.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,13 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
432432
self.explicit_implied_predicates_of(def_id).map_bound(|preds| preds.into_iter().copied())
433433
}
434434

435+
fn impl_super_outlives(
436+
self,
437+
impl_def_id: DefId,
438+
) -> ty::EarlyBinder<'tcx, impl IntoIterator<Item = ty::Clause<'tcx>>> {
439+
self.impl_super_outlives(impl_def_id)
440+
}
441+
435442
fn impl_is_const(self, def_id: DefId) -> bool {
436443
debug_assert_matches!(self.def_kind(def_id), DefKind::Impl { of_trait: true });
437444
self.is_conditionally_const(def_id)

‎compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,12 @@ where
103103
// We currently elaborate all supertrait outlives obligations from impls.
104104
// This can be removed when we actually do coinduction correctly, and prove
105105
// all supertrait obligations unconditionally.
106-
let goal_clause: I::Clause = goal.predicate.upcast(cx);
107-
for clause in elaborate::elaborate(cx, [goal_clause]) {
108-
if matches!(
109-
clause.kind().skip_binder(),
110-
ty::ClauseKind::TypeOutlives(..) | ty::ClauseKind::RegionOutlives(..)
111-
) {
112-
ecx.add_goal(GoalSource::Misc, goal.with(cx, clause));
113-
}
114-
}
106+
ecx.add_goals(
107+
GoalSource::Misc,
108+
cx.impl_super_outlives(impl_def_id)
109+
.iter_instantiated(cx, impl_args)
110+
.map(|pred| goal.with(cx, pred)),
111+
);
115112

116113
ecx.evaluate_added_goals_and_make_canonical_response(maximal_certainty)
117114
})

‎compiler/rustc_type_ir/src/interner.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ pub trait Interner:
271271
def_id: Self::DefId,
272272
) -> ty::EarlyBinder<Self, impl IntoIterator<Item = (Self::Clause, Self::Span)>>;
273273

274+
/// This is equivalent to computing the super-predicates of the trait for this impl
275+
/// and filtering them to the outlives predicates. This is purely for performance.
276+
fn impl_super_outlives(
277+
self,
278+
impl_def_id: Self::DefId,
279+
) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
280+
274281
fn impl_is_const(self, def_id: Self::DefId) -> bool;
275282
fn fn_is_const(self, def_id: Self::DefId) -> bool;
276283
fn alias_has_const_conditions(self, def_id: Self::DefId) -> bool;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /