]> git.lizzy.rs Git - rust.git/commitdiff
Micro-optimization in consider_assumption
authorMichael Goulet <michael@errs.io>
Fri, 27 Jan 2023 04:32:12 +0000 (04:32 +0000)
committerMichael Goulet <michael@errs.io>
Fri, 27 Jan 2023 20:06:12 +0000 (20:06 +0000)
compiler/rustc_trait_selection/src/solve/project_goals.rs
compiler/rustc_trait_selection/src/solve/trait_goals.rs

index b583705ac43693a6619c1776ce1df2efe37bea02..9da464f283ef394d2cef6fba21003fdbdc879ad8 100644 (file)
@@ -296,7 +296,9 @@ fn consider_assumption(
         goal: Goal<'tcx, Self>,
         assumption: ty::Predicate<'tcx>,
     ) -> QueryResult<'tcx> {
-        if let Some(poly_projection_pred) = assumption.to_opt_poly_projection_pred() {
+        if let Some(poly_projection_pred) = assumption.to_opt_poly_projection_pred()
+            && poly_projection_pred.projection_def_id() == goal.predicate.def_id()
+        {
             ecx.infcx.probe(|_| {
                 let assumption_projection_pred =
                     ecx.infcx.instantiate_bound_vars_with_infer(poly_projection_pred);
index d74857dc4b4803bac6b418941d6e9122dd1fae3b..45b6a5f4ec578b3ce19b4c9f60a03c9649fc88b5 100644 (file)
@@ -65,7 +65,9 @@ fn consider_assumption(
         goal: Goal<'tcx, Self>,
         assumption: ty::Predicate<'tcx>,
     ) -> QueryResult<'tcx> {
-        if let Some(poly_trait_pred) = assumption.to_opt_poly_trait_pred() {
+        if let Some(poly_trait_pred) = assumption.to_opt_poly_trait_pred()
+            && poly_trait_pred.def_id() == goal.predicate.def_id()
+        {
             // FIXME: Constness and polarity
             ecx.infcx.probe(|_| {
                 let assumption_trait_pred =