@@ -42,11 +42,14 @@ newtype TType =
42
42
TStruct ( Struct s ) or
43
43
TEnum ( Enum e ) or
44
44
TTrait ( Trait t ) or
45
+ TUnion ( Union u ) or
45
46
TArrayType ( ) or // todo: add size?
46
47
TRefType ( ) or // todo: add mut?
47
48
TImplTraitType ( ImplTraitTypeRepr impl ) or
48
49
TDynTraitType ( Trait t ) { t = any ( DynTraitTypeRepr dt ) .getTrait ( ) } or
49
50
TSliceType ( ) or
51
+ TNeverType ( ) or
52
+ TPtrType ( ) or
50
53
TTupleTypeParameter ( int arity , int i ) { exists ( TTuple ( arity ) ) and i in [ 0 .. arity - 1 ] } or
51
54
TTypeParamTypeParameter ( TypeParam t ) or
52
55
TAssociatedTypeTypeParameter ( TypeAlias t ) { any ( TraitItemNode trait ) .getAnAssocItem ( ) = t } or
@@ -57,7 +60,8 @@ newtype TType =
57
60
} or
58
61
TRefTypeParameter ( ) or
59
62
TSelfTypeParameter ( Trait t ) or
60
- TSliceTypeParameter ( )
63
+ TSliceTypeParameter ( ) or
64
+ TPtrTypeParameter ( )
61
65
62
66
private predicate implTraitTypeParam ( ImplTraitTypeRepr implTrait , int i , TypeParam tp ) {
63
67
implTrait .isInReturnPos ( ) and
@@ -224,6 +228,31 @@ class TraitType extends Type, TTrait {
224
228
override Location getLocation ( ) { result = trait .getLocation ( ) }
225
229
}
226
230
231
+ /** A union type. */
232
+ class UnionType extends StructOrEnumType , TUnion {
233
+ private Union union ;
234
+
235
+ UnionType ( ) { this = TUnion ( union ) }
236
+
237
+ override ItemNode asItemNode ( ) { result = union }
238
+
239
+ override StructField getStructField ( string name ) { result = union .getStructField ( name ) }
240
+
241
+ override TupleField getTupleField ( int i ) { none ( ) }
242
+
243
+ override TypeParameter getPositionalTypeParameter ( int i ) {
244
+ result = TTypeParamTypeParameter ( union .getGenericParamList ( ) .getTypeParam ( i ) )
245
+ }
246
+
247
+ override TypeMention getTypeParameterDefault ( int i ) {
248
+ result = union .getGenericParamList ( ) .getTypeParam ( i ) .getDefaultType ( )
249
+ }
250
+
251
+ override string toString ( ) { result = union .getName ( ) .getText ( ) }
252
+
253
+ override Location getLocation ( ) { result = union .getLocation ( ) }
254
+ }
255
+
227
256
/**
228
257
* An array type.
229
258
*
@@ -374,6 +403,33 @@ class SliceType extends Type, TSliceType {
374
403
override Location getLocation ( ) { result instanceof EmptyLocation }
375
404
}
376
405
406
+ class NeverType extends Type , TNeverType {
407
+ override StructField getStructField ( string name ) { none ( ) }
408
+
409
+ override TupleField getTupleField ( int i ) { none ( ) }
410
+
411
+ override TypeParameter getPositionalTypeParameter ( int i ) { none ( ) }
412
+
413
+ override string toString ( ) { result = "!" }
414
+
415
+ override Location getLocation ( ) { result instanceof EmptyLocation }
416
+ }
417
+
418
+ class PtrType extends Type , TPtrType {
419
+ override StructField getStructField ( string name ) { none ( ) }
420
+
421
+ override TupleField getTupleField ( int i ) { none ( ) }
422
+
423
+ override TypeParameter getPositionalTypeParameter ( int i ) {
424
+ i = 0 and
425
+ result = TPtrTypeParameter ( )
426
+ }
427
+
428
+ override string toString ( ) { result = "*" }
429
+
430
+ override Location getLocation ( ) { result instanceof EmptyLocation }
431
+ }
432
+
377
433
/** A type parameter. */
378
434
abstract class TypeParameter extends Type {
379
435
override StructField getStructField ( string name ) { none ( ) }
@@ -529,6 +585,12 @@ class SliceTypeParameter extends TypeParameter, TSliceTypeParameter {
529
585
override Location getLocation ( ) { result instanceof EmptyLocation }
530
586
}
531
587
588
+ class PtrTypeParameter extends TypeParameter , TPtrTypeParameter {
589
+ override string toString ( ) { result = "*T" }
590
+
591
+ override Location getLocation ( ) { result instanceof EmptyLocation }
592
+ }
593
+
532
594
/**
533
595
* The implicit `Self` type parameter of a trait, that refers to the
534
596
* implementing type of the trait.
0 commit comments