From e37a7a1f74afb0b62b933af4439d271f4b8f890a Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Wed, 5 Jun 2019 21:08:36 +0100 Subject: [PATCH] add an example to `create_substs_for_ast_path` --- src/librustc_typeck/astconv.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7f2d3c8e424..34f817ba570 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -573,6 +573,20 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// set of substitutions. This may involve applying defaulted type parameters. /// Also returns back constriants on associated types. /// + /// Example: + /// + /// ``` + /// T: std::ops::Index + /// ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4 + /// ``` + /// + /// 1. The `self_ty` here would refer to the type `T`. + /// 2. The path in question is the path to the trait `std::ops::Index`, + /// which will have been resolved to a `def_id` + /// 3. The `generic_args` contains info on the `<...>` contents. The `usize` type + /// parameters are returned in the `SubstsRef`, the associated type bindings like + /// `Output = u32` are returned in the `Vec` result. + /// /// Note that the type listing given here is *exactly* what the user provided. fn create_substs_for_ast_path<'a>(&self, span: Span,