Skip to content

Commit e37a7a1

Browse files
author
Alexander Regueiro
committed
add an example to create_substs_for_ast_path
1 parent a900427 commit e37a7a1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/librustc_typeck/astconv.rs

+14
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,20 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
573573
/// set of substitutions. This may involve applying defaulted type parameters.
574574
/// Also returns back constriants on associated types.
575575
///
576+
/// Example:
577+
///
578+
/// ```
579+
/// T: std::ops::Index<usize, Output = u32>
580+
/// ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4
581+
/// ```
582+
///
583+
/// 1. The `self_ty` here would refer to the type `T`.
584+
/// 2. The path in question is the path to the trait `std::ops::Index`,
585+
/// which will have been resolved to a `def_id`
586+
/// 3. The `generic_args` contains info on the `<...>` contents. The `usize` type
587+
/// parameters are returned in the `SubstsRef`, the associated type bindings like
588+
/// `Output = u32` are returned in the `Vec<ConvertedBinding...>` result.
589+
///
576590
/// Note that the type listing given here is *exactly* what the user provided.
577591
fn create_substs_for_ast_path<'a>(&self,
578592
span: Span,

0 commit comments

Comments
 (0)