Skip to content

Commit 538ebd1

Browse files
nikomatsakisAlexander Regueiro
authored andcommitted
Added some comments, made add_bounds private.
1 parent 0f4a5ca commit 538ebd1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
699699
},
700700
);
701701

702+
// Convert associated-type bindings or constraints into a separate vector.
703+
// Example: Given this:
704+
//
705+
// T: Iterator<Item = u32>
706+
//
707+
// The `T` is passed in as a self-type; the `Item = u32` is
708+
// not a "type parameter" of the `Iterator` trait, but rather
709+
// a restriction on `<T as Iterator>::Item`, so it is passed
710+
// back separately.
702711
let assoc_bindings = generic_args.bindings.iter()
703712
.map(|binding| {
704713
let kind = if let hir::TyKind::AssocTyExistential(ref bounds) = binding.ty.node {
@@ -899,7 +908,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
899908
true
900909
}
901910

902-
pub fn add_bounds(&self,
911+
fn add_bounds(&self,
903912
param_ty: Ty<'tcx>,
904913
ast_bounds: &[hir::GenericBound],
905914
bounds: &mut Bounds<'tcx>,
@@ -1065,6 +1074,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
10651074

10661075
match binding.kind {
10671076
ConvertedBindingKind::Equality(ref ty) => {
1077+
// "Desugar" a constraint like `T: Iterator<Item = u32>` this to
1078+
// the "projection predicate" for:
1079+
//
1080+
// `<T as Iterator>::Item = u32`
10681081
bounds.projection_bounds.push((candidate.map_bound(|trait_ref| {
10691082
ty::ProjectionPredicate {
10701083
projection_ty: ty::ProjectionTy::from_ref_and_name(

0 commit comments

Comments
 (0)