Skip to content

Commit 709b924

Browse files
author
Alexander Regueiro
committed
Ensure type_param_predicates fn only returns predicates for type param with given def-ID.
1 parent 3d9d36b commit 709b924

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ pub struct ParamEnv<'tcx> {
16491649
/// `Obligation`s that the caller must satisfy. This is basically
16501650
/// the set of bounds on the in-scope type parameters, translated
16511651
/// into `Obligation`s, and elaborated and normalized.
1652-
pub caller_bounds: &'tcx List<(ty::Predicate<'tcx>, Span)>,
1652+
pub caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
16531653

16541654
/// Typically, this is `Reveal::UserFacing`, but during codegen we
16551655
/// want `Reveal::All` -- note that this is always paired with an

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
806806
binding,
807807
bounds,
808808
speculative,
809-
&mut dup_bindings
809+
&mut dup_bindings,
810810
);
811811
// Okay to ignore `Err` because of `ErrorReported` (see above).
812812
}

src/librustc_typeck/collect.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,16 @@ fn type_param_predicates(
322322
let icx = ItemCtxt::new(tcx, item_def_id);
323323
let mut result = (*result).clone();
324324
result.predicates.extend(extend.into_iter());
325-
result.predicates
326-
.extend(icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty,
327-
OnlySelfBounds(true)));
325+
result.predicates.extend(
326+
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
327+
.into_iter()
328+
.filter(|(predicate, _)| {
329+
match predicate {
330+
ty::Predicate::Trait(ref data) => data.skip_binder().self_ty().is_param(index),
331+
_ => false,
332+
}
333+
})
334+
);
328335
tcx.arena.alloc(result)
329336
}
330337

@@ -2300,7 +2307,6 @@ fn predicates_from_bound<'tcx>(
23002307
tr,
23012308
param_ty,
23022309
&mut bounds,
2303-
false,
23042310
);
23052311
bounds.predicates(astconv.tcx(), param_ty)
23062312
}

0 commit comments

Comments
 (0)