File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 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…
127127 ` MyStruct ` : ` Adt(Foo, &[Param(0), Param(1)]) ` .
128128
129129** ` 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.
133131
134132[ Here is an example of actually using ` instantiate ` in the compiler] [ instantiatex ] .
135133The exact details are not too important, but in this piece of code, we happen to be
136134converting from the ` rustc_hir::Ty ` to a real ` ty::Ty ` . You can see that we first get some args
137135(` args ` ). Then we call ` type_of ` to get a type and call ` ty.instantiate(tcx, args) ` to get a new
138136version of ` ty ` with the args made.
139137
138+ [ instantiate ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/generic_args/struct.EarlyBinder.html#method.instantiate
140139[ instantiatex ] : https://github.com/rust-lang/rust/blob/8a562f9671e36cf29c9c794c2646bcf252d55535/compiler/rustc_hir_analysis/src/astconv/mod.rs#L905-L927
141140
142141** 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