diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2019-05-31 17:15:15 -0400 |
|---|---|---|
| committer | Alexander Regueiro <alexreg@me.com> | 2019-06-05 21:18:13 +0100 |
| commit | 83078f0b37fd944f09bcfce4f8d476814b936aae (patch) | |
| tree | 1c9cd78a6e28f49037f42daca764be4012551cd2 | |
| parent | f6ee542f16785fd944a663b8f4bc203ad150d2de (diff) | |
| download | rust-83078f0b37fd944f09bcfce4f8d476814b936aae.tar.gz rust-83078f0b37fd944f09bcfce4f8d476814b936aae.zip | |
comment `instantiate_poly_trait_ref` and its binder behavior
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 2ba6601e826..28c5c13492a 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -792,6 +792,25 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { (poly_trait_ref, potential_assoc_types) } + /// Given a trait bound like `Debug`, applies that trait bound the given self-type to construct + /// a full trait reference. The resulting trait reference is returned. This may also generate + /// auxiliary bounds, which are added to `bounds`. + /// + /// Example: + /// + /// ``` + /// poly_trait_ref = Iterator<Item = u32> + /// self_ty = Foo + /// ``` + /// + /// this would return `Foo: Iterator` and add `<Foo as Iterator>::Item = u32` into `bounds`. + /// + /// **A note on binders:** against our usual convention, there is an implied bounder around + /// the `self_ty` and `poly_trait_ref` parameters here. So they may reference bound regions. + /// If for example you had `for<'a> Foo<'a>: Bar<'a>`, then the `self_ty` would be `Foo<'a>` + /// where `'a` is a bound region at depth 0. Similarly, the `poly_trait_ref` would be + /// `Bar<'a>`. The returned poly-trait-ref will have this binder instantiated explicitly, + /// however. pub fn instantiate_poly_trait_ref(&self, poly_trait_ref: &hir::PolyTraitRef, self_ty: Ty<'tcx>, |
