@@ -13,7 +13,6 @@ newtype TType =
13
13
TStruct ( Struct s ) { Stages:: TypeInferenceStage:: ref ( ) } or
14
14
TEnum ( Enum e ) or
15
15
TTrait ( Trait t ) or
16
- TImpl ( Impl i ) or
17
16
TArrayType ( ) or // todo: add size?
18
17
TRefType ( ) or // todo: add mut?
19
18
TTypeParamTypeParameter ( TypeParam t ) or
@@ -132,75 +131,6 @@ class TraitType extends Type, TTrait {
132
131
override Location getLocation ( ) { result = trait .getLocation ( ) }
133
132
}
134
133
135
- /**
136
- * An `impl` block type.
137
- *
138
- * Although `impl` blocks are not really types, we treat them as such in order
139
- * to be able to match type parameters from structs (or enums) with type
140
- * parameters from `impl` blocks. For example, in
141
- *
142
- * ```rust
143
- * struct S<T1>(T1);
144
- *
145
- * impl<T2> S<T2> {
146
- * fn id(self) -> S<T2> { self }
147
- * }
148
- *
149
- * let x : S(i64) = S(42);
150
- * x.id();
151
- * ```
152
- *
153
- * we pretend that the `impl` block is a base type mention of the struct `S`,
154
- * with type argument `T1`. This means that from knowing that `x` has type
155
- * `S(i64)`, we can first match `i64` with `T1`, and then by matching `T1` with
156
- * `T2`, we can match `i64` with `T2`.
157
- *
158
- * `impl` blocks can also have base type mentions, namely the trait that they
159
- * implement (if any). Example:
160
- *
161
- * ```rust
162
- * struct S<T1>(T1);
163
- *
164
- * trait Trait<T2> {
165
- * fn f(self) -> T2;
166
- *
167
- * fn g(self) -> T2 { self.f() }
168
- * }
169
- *
170
- * impl<T3> Trait<T3> for S<T3> { // `Trait<T3>` is a base type mention of this `impl` block
171
- * fn f(self) -> T3 {
172
- * match self {
173
- * S(x) => x
174
- * }
175
- * }
176
- * }
177
- *
178
- * let x : S(i64) = S(42);
179
- * x.g();
180
- * ```
181
- *
182
- * In this case we can match `i64` with `T1`, `T1` with `T3`, and `T3` with `T2`,
183
- * allowing us match `i64` with `T2`, and hence infer that the return type of `g`
184
- * is `i64`.
185
- */
186
- class ImplType extends Type , TImpl {
187
- private Impl impl ;
188
-
189
- ImplType ( ) { this = TImpl ( impl ) }
190
-
191
- override StructField getStructField ( string name ) { none ( ) }
192
-
193
- override TupleField getTupleField ( int i ) { none ( ) }
194
-
195
- override TypeParameter getTypeParameter ( int i ) {
196
- result = TTypeParamTypeParameter ( impl .getGenericParamList ( ) .getTypeParam ( i ) )
197
- }
198
-
199
- override string toString ( ) { result = impl .toString ( ) }
200
-
201
- override Location getLocation ( ) { result = impl .getLocation ( ) }
202
- }
203
-
204
134
/**
205
135
* An array type.
206
136
*
0 commit comments