]> git.lizzy.rs Git - rust.git/commitdiff
Ensure `type_param_predicates` fn only returns predicates for type param with given...
authorAlexander Regueiro <alexreg@me.com>
Mon, 17 Jun 2019 22:41:20 +0000 (23:41 +0100)
committerAlexander Regueiro <alexreg@me.com>
Mon, 5 Aug 2019 14:16:27 +0000 (15:16 +0100)
src/librustc/ty/mod.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/collect.rs

index c6aadc598b7e1d1be8ad345fb82d0cac9a31457d..1eda57608e75b8460a3d9f65603b73de2c45b25a 100644 (file)
@@ -1649,7 +1649,7 @@ pub struct ParamEnv<'tcx> {
     /// `Obligation`s that the caller must satisfy. This is basically
     /// the set of bounds on the in-scope type parameters, translated
     /// into `Obligation`s, and elaborated and normalized.
-    pub caller_bounds: &'tcx List<(ty::Predicate<'tcx>, Span)>,
+    pub caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
 
     /// Typically, this is `Reveal::UserFacing`, but during codegen we
     /// want `Reveal::All` -- note that this is always paired with an
index 64c0011a7b39c9ec7d2d29cddc640f4e8daa8345..881f66afc91dfcbb56b964c3e1156d01b317f1d6 100644 (file)
@@ -806,7 +806,7 @@ pub(super) fn instantiate_poly_trait_ref_inner(&self,
                     binding,
                     bounds,
                     speculative,
-                    &mut dup_bindings
+                    &mut dup_bindings,
                 );
             // Okay to ignore `Err` because of `ErrorReported` (see above).
         }
index 4056d6f974c5d9b509a0aa5776f9e0a124743bec..357dcd878f51521bdb9822b2533c1589d4c1c37e 100644 (file)
@@ -322,9 +322,16 @@ fn type_param_predicates(
     let icx = ItemCtxt::new(tcx, item_def_id);
     let mut result = (*result).clone();
     result.predicates.extend(extend.into_iter());
-    result.predicates
-          .extend(icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty,
-                  OnlySelfBounds(true)));
+    result.predicates.extend(
+        icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
+            .into_iter()
+            .filter(|(predicate, _)| {
+                match predicate {
+                    ty::Predicate::Trait(ref data) => data.skip_binder().self_ty().is_param(index),
+                    _ => false,
+                }
+            })
+    );
     tcx.arena.alloc(result)
 }
 
@@ -2300,7 +2307,6 @@ fn predicates_from_bound<'tcx>(
                 tr,
                 param_ty,
                 &mut bounds,
-                false,
             );
             bounds.predicates(astconv.tcx(), param_ty)
         }