Rust: Address review comments

This commit is contained in:
Simon Friis Vindum
2025-12-19 13:53:38 +01:00
parent dde845e92f
commit e0e493a9e3
2 changed files with 15 additions and 9 deletions

View File

@@ -133,26 +133,32 @@ class DataType extends Type, TDataType {
/** A struct type. */
class StructType extends DataType {
StructType() { super.getTypeItem() instanceof Struct }
private Struct struct;
StructType() { struct = super.getTypeItem() }
/** Gets the struct that this struct type represents. */
override Struct getTypeItem() { result = super.getTypeItem() }
override Struct getTypeItem() { result = struct }
}
/** An enum type. */
class EnumType extends DataType {
EnumType() { super.getTypeItem() instanceof Enum }
private Enum enum;
EnumType() { enum = super.getTypeItem() }
/** Gets the enum that this enum type represents. */
override Enum getTypeItem() { result = super.getTypeItem() }
override Enum getTypeItem() { result = enum }
}
/** A union type. */
class UnionType extends DataType {
UnionType() { super.getTypeItem() instanceof Union }
private Union union;
UnionType() { union = super.getTypeItem() }
/** Gets the union that this union type represents. */
override Union getTypeItem() { result = super.getTypeItem() }
override Union getTypeItem() { result = union }
}
/** A trait type. */

View File

@@ -907,7 +907,7 @@ private module StructExprMatchingInput implements MatchingInputSig {
result = this.getTypeParameter(_) and
path = TypePath::singleton(result)
or
// type of the struct itself
// type of the struct or enum itself
dpos.isStructPos() and
path.isEmpty() and
result = TDataType(this.getTypeItem())
@@ -2860,7 +2860,7 @@ private class TupleLikeStruct extends TupleLikeConstructor instanceof Struct {
override TypeItem getTypeItem() { result = this }
override TupleField getTupleField(int i) { result = this.(Struct).getTupleField(i) }
override TupleField getTupleField(int i) { result = Struct.super.getTupleField(i) }
}
private class TupleLikeVariant extends TupleLikeConstructor instanceof Variant {
@@ -2868,7 +2868,7 @@ private class TupleLikeVariant extends TupleLikeConstructor instanceof Variant {
override TypeItem getTypeItem() { result = super.getEnum() }
override TupleField getTupleField(int i) { result = this.(Variant).getTupleField(i) }
override TupleField getTupleField(int i) { result = Variant.super.getTupleField(i) }
}
/**