@@ -6,20 +6,20 @@ inference, type checking, and trait solving. Conceptually, during these routines
66that one type is equal to another type and want to swap one out for the other and then swap that out
77for another type and so on until we eventually get some concrete types (or an error).
88
9- In rustc this is done using [ GenericArgsRef ] .
10- Conceptually, you can think of ` GenericArgsRef ` as a list of types that are to be substituted for
9+ In rustc this is done using [ GenericArgs ] .
10+ Conceptually, you can think of ` GenericArgs ` as a list of types that are to be substituted for
1111 the generic type parameters of the ADT.
1212
13- ` GenericArgsRef ` is a type alias of ` &'tcx List<GenericArg<'tcx>> ` (see [ ` List ` rustdocs] [ list ] ).
13+ ` GenericArgs ` is a type alias of ` &'tcx List<GenericArg<'tcx>> ` (see [ ` List ` rustdocs] [ list ] ).
1414[ ` GenericArg ` ] is essentially a space-efficient wrapper around [ ` GenericArgKind ` ] , which is an enum
1515indicating what kind of generic the type parameter is (type, lifetime, or const).
16- Thus, ` GenericArgsRef ` is conceptually like a ` &'tcx [GenericArgKind<'tcx>] ` slice (but it is
16+ Thus, ` GenericArgs ` is conceptually like a ` &'tcx [GenericArgKind<'tcx>] ` slice (but it is
1717actually a ` List ` ).
1818
1919[ list ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.List.html
2020[ `GenericArg` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.GenericArg.html
2121[ `GenericArgKind` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.GenericArgKind.html
22- [ GenericArgsRef ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/type.GenericArgsRef .html
22+ [ GenericArgs ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/type.GenericArgs .html
2323
2424So why do we use this ` List ` type instead of making it really a slice? It has the length "inline",
2525so ` &List ` is only 32 bits. As a consequence, it cannot be "subsliced" (that only works if the
@@ -37,10 +37,10 @@ struct MyStruct<T>
3737
3838- There would be an ` AdtDef ` (and corresponding ` DefId ` ) for ` MyStruct ` .
3939- There would be a ` TyKind::Param ` (and corresponding ` DefId ` ) for ` T ` (more later).
40- - There would be a ` GenericArgsRef ` containing the list ` [GenericArgKind::Type(Ty(T))] `
40+ - There would be a ` GenericArgs ` containing the list ` [GenericArgKind::Type(Ty(T))] `
4141 - The ` Ty(T) ` here is my shorthand for entire other ` ty::Ty ` that has ` TyKind::Param ` , which we
4242 mentioned in the previous point.
43- - This is one ` TyKind::Adt ` containing the ` AdtDef ` of ` MyStruct ` with the ` GenericArgsRef ` above.
43+ - This is one ` TyKind::Adt ` containing the ` AdtDef ` of ` MyStruct ` with the ` GenericArgs ` above.
4444
4545Finally, we will quickly mention the
4646[ ` Generics ` ] ( https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Generics.html ) type. It
@@ -114,7 +114,7 @@ This example has a few different substitutions:
114114
115115Let’s look a bit more closely at that last substitution to see why we use indexes. If we want to
116116find the type of ` foo.x ` , we can get generic type of ` x ` , which is ` Vec<Param(0)> ` . Now we can take
117- the index ` 0 ` and use it to find the right type substitution: looking at ` Foo ` 's ` GenericArgsRef ` ,
117+ the index ` 0 ` and use it to find the right type substitution: looking at ` Foo ` 's ` GenericArgs ` ,
118118we have the list ` [u32, f32] ` , since we want to replace index ` 0 ` , we take the 0-th index of this
119119list, which is ` u32 ` . Voila!
120120
@@ -127,7 +127,7 @@ You may have a couple of followup questions…
127127 ` MyStruct ` : ` Adt(Foo, &[Param(0), Param(1)]) ` .
128128
129129How do we actually do the substitutions? There is a function for that too! You
130- use [ ` instantiate ` ] to replace a ` GenericArgsRef ` with another list of types.
130+ use [ ` instantiate ` ] to replace a ` GenericArgs ` with another list of types.
131131
132132[ Here is an example of actually using ` instantiate ` in the compiler] [ instantiatex ] .
133133The exact details are not too important, but in this piece of code, we happen to be
0 commit comments