File tree 1 file changed +2
-3
lines changed
1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -127,16 +127,15 @@ You may have a couple of followup questions…
127
127
` MyStruct ` : ` Adt(Foo, &[Param(0), Param(1)]) ` .
128
128
129
129
** ` instantiate ` ** How do we actually do the substitutions? There is a function for that too! You
130
- use [ ` instantiate ` ] (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/
131
- generic_args/struct.EarlyBinder.html#method.instantiate) to replace a ` GenericArgsRef ` with
132
- another list of types.
130
+ use [ ` instantiate ` ] [ instantiate ] to replace a ` GenericArgsRef ` with another list of types.
133
131
134
132
[ Here is an example of actually using ` instantiate ` in the compiler] [ instantiatex ] .
135
133
The exact details are not too important, but in this piece of code, we happen to be
136
134
converting from the ` rustc_hir::Ty ` to a real ` ty::Ty ` . You can see that we first get some args
137
135
(` args ` ). Then we call ` type_of ` to get a type and call ` ty.instantiate(tcx, args) ` to get a new
138
136
version of ` ty ` with the args made.
139
137
138
+ [ instantiate ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/generic_args/struct.EarlyBinder.html#method.instantiate
140
139
[ instantiatex ] : https://github.com/rust-lang/rust/blob/8a562f9671e36cf29c9c794c2646bcf252d55535/compiler/rustc_hir_analysis/src/astconv/mod.rs#L905-L927
141
140
142
141
** Note on indices:** It is possible for the indices in ` Param ` to not match with what we expect. For
You can’t perform that action at this time.
0 commit comments