about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-11 17:01:44 +0000
committerbors <bors@rust-lang.org>2023-01-11 17:01:44 +0000
commitef4046e4f3932991971cdb64915172899532aece (patch)
tree0d19af73ce4d98d239abf182b4dc07a44dff124f /compiler/rustc_trait_selection/src
parentb22c152958eade17a71d899b29a2d39bcc77aa48 (diff)
parent9aeef61820b4cd14b3f4cab601a95b15ced5862e (diff)
downloadrust-ef4046e4f3932991971cdb64915172899532aece.tar.gz
rust-ef4046e4f3932991971cdb64915172899532aece.zip
Auto merge of #106730 - Nilstrieb:rollup-f7p8dsa, r=Nilstrieb
Rollup of 9 pull requests

Successful merges:

 - #106321 (Collect and emit proper backtraces for `delay_span_bug`s)
 - #106397 (Check `impl`'s `where` clauses in `consider_impl_candidate` in experimental solver)
 - #106427 (Improve fluent error messages)
 - #106570 (add tests for div_duration_* functions)
 - #106648 (Polymorphization cleanup)
 - #106664 (Remove unnecessary lseek syscall when using std::fs::read)
 - #106709 (Disable "split dwarf inlining" by default.)
 - #106715 (Autolabel and ping wg for changes to new solver)
 - #106717 (fix typo LocalItemId -> ItemLocalId)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/solve/project_goals.rs10
-rw-r--r--compiler/rustc_trait_selection/src/solve/trait_goals.rs17
2 files changed, 21 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs
index b50f42c4d94..3d649bea19d 100644
--- a/compiler/rustc_trait_selection/src/solve/project_goals.rs
+++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs
@@ -131,8 +131,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
             else {
                 return
             };
-
-            let nested_goals = obligations.into_iter().map(|o| o.into()).collect();
+            let where_clause_bounds = tcx
+                .predicates_of(impl_def_id)
+                .instantiate(tcx, impl_substs)
+                .predicates
+                .into_iter()
+                .map(|pred| goal.with(tcx, pred));
+
+            let nested_goals = obligations.into_iter().map(|o| o.into()).chain(where_clause_bounds).collect();
             let Ok(trait_ref_certainty) = acx.cx.evaluate_all(acx.infcx, nested_goals) else { return };
 
             let Some(assoc_def) = fetch_eligible_assoc_item_def(
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs
index 10b45a77dab..c69cc39acb5 100644
--- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs
+++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs
@@ -71,7 +71,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
         goal: Goal<'tcx, TraitPredicate<'tcx>>,
         impl_def_id: DefId,
     ) {
-        let impl_trait_ref = acx.cx.tcx.bound_impl_trait_ref(impl_def_id).unwrap();
+        let tcx = acx.cx.tcx;
+
+        let impl_trait_ref = tcx.bound_impl_trait_ref(impl_def_id).unwrap();
         let drcx = DeepRejectCtxt { treat_obligation_params: TreatParams::AsPlaceholder };
         if iter::zip(goal.predicate.trait_ref.substs, impl_trait_ref.skip_binder().substs)
             .any(|(goal, imp)| !drcx.generic_args_may_unify(goal, imp))
@@ -81,7 +83,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
 
         acx.infcx.probe(|_| {
             let impl_substs = acx.infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id);
-            let impl_trait_ref = impl_trait_ref.subst(acx.cx.tcx, impl_substs);
+            let impl_trait_ref = impl_trait_ref.subst(tcx, impl_substs);
 
             let Ok(InferOk { obligations, .. }) = acx
                 .infcx
@@ -92,8 +94,15 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
             else {
                 return
             };
-
-            let nested_goals = obligations.into_iter().map(|o| o.into()).collect();
+            let where_clause_bounds = tcx
+                .predicates_of(impl_def_id)
+                .instantiate(tcx, impl_substs)
+                .predicates
+                .into_iter()
+                .map(|pred| goal.with(tcx, pred));
+
+            let nested_goals =
+                obligations.into_iter().map(|o| o.into()).chain(where_clause_bounds).collect();
 
             let Ok(certainty) = acx.cx.evaluate_all(acx.infcx, nested_goals) else { return };
             acx.try_insert_candidate(CandidateSource::Impl(impl_def_id), certainty);