mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
Rust: Add unit type
This commit is contained in:
@@ -9,6 +9,7 @@ private import codeql.rust.elements.internal.generated.Synth
|
||||
|
||||
cached
|
||||
newtype TType =
|
||||
TUnit() or
|
||||
TStruct(Struct s) { Stages::TypeInferenceStage::ref() } or
|
||||
TEnum(Enum e) or
|
||||
TTrait(Trait t) or
|
||||
@@ -48,6 +49,21 @@ abstract class Type extends TType {
|
||||
abstract Location getLocation();
|
||||
}
|
||||
|
||||
/** The unit type `()`. */
|
||||
class UnitType extends Type, TUnit {
|
||||
UnitType() { this = TUnit() }
|
||||
|
||||
override StructField getStructField(string name) { none() }
|
||||
|
||||
override TupleField getTupleField(int i) { none() }
|
||||
|
||||
override TypeParameter getTypeParameter(int i) { none() }
|
||||
|
||||
override string toString() { result = "()" }
|
||||
|
||||
override Location getLocation() { result instanceof EmptyLocation }
|
||||
}
|
||||
|
||||
abstract private class StructOrEnumType extends Type {
|
||||
abstract ItemNode asItemNode();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user