Skip to content

Commit

Permalink
Ensure type_param_predicates fn only returns predicates for type pa…
Browse files Browse the repository at this point in the history
…ram with given def-ID.
  • Loading branch information
Alexander Regueiro committed Aug 5, 2019
1 parent 3d9d36b commit 709b924
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Expand Up @@ -806,7 +806,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
binding,
bounds,
speculative,
&mut dup_bindings
&mut dup_bindings,
);
// Okay to ignore `Err` because of `ErrorReported` (see above).
}
Expand Down
14 changes: 10 additions & 4 deletions src/librustc_typeck/collect.rs
Expand Up @@ -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)
}

Expand Down Expand Up @@ -2300,7 +2307,6 @@ fn predicates_from_bound<'tcx>(
tr,
param_ty,
&mut bounds,
false,
);
bounds.predicates(astconv.tcx(), param_ty)
}
Expand Down

0 comments on commit 709b924

Please sign in to comment.