Skip to content

Commit 83078f0

Browse files
nikomatsakisAlexander Regueiro
authored and
Alexander Regueiro
committed
comment instantiate_poly_trait_ref and its binder behavior
1 parent f6ee542 commit 83078f0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/librustc_typeck/astconv.rs

+19
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,25 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
792792
(poly_trait_ref, potential_assoc_types)
793793
}
794794

795+
/// Given a trait bound like `Debug`, applies that trait bound the given self-type to construct
796+
/// a full trait reference. The resulting trait reference is returned. This may also generate
797+
/// auxiliary bounds, which are added to `bounds`.
798+
///
799+
/// Example:
800+
///
801+
/// ```
802+
/// poly_trait_ref = Iterator<Item = u32>
803+
/// self_ty = Foo
804+
/// ```
805+
///
806+
/// this would return `Foo: Iterator` and add `<Foo as Iterator>::Item = u32` into `bounds`.
807+
///
808+
/// **A note on binders:** against our usual convention, there is an implied bounder around
809+
/// the `self_ty` and `poly_trait_ref` parameters here. So they may reference bound regions.
810+
/// If for example you had `for<'a> Foo<'a>: Bar<'a>`, then the `self_ty` would be `Foo<'a>`
811+
/// where `'a` is a bound region at depth 0. Similarly, the `poly_trait_ref` would be
812+
/// `Bar<'a>`. The returned poly-trait-ref will have this binder instantiated explicitly,
813+
/// however.
795814
pub fn instantiate_poly_trait_ref(&self,
796815
poly_trait_ref: &hir::PolyTraitRef,
797816
self_ty: Ty<'tcx>,

0 commit comments

Comments
 (0)