@@ -186,6 +186,8 @@ class ImplTraitType : public Type
186186 {
187187 return type_param_bounds;
188188 }
189+
190+ Type::Kind get_type_kind () const override { return Type::Kind::ImplTrait; }
189191};
190192
191193// An opaque value of another type that implements a set of traits
@@ -258,6 +260,8 @@ class TraitObjectType : public Type
258260 {
259261 return type_param_bounds;
260262 }
263+
264+ Type::Kind get_type_kind () const override { return Type::Kind::TraitObject; }
261265};
262266
263267// A type with parentheses around it, used to avoid ambiguity.
@@ -326,6 +330,11 @@ class ParenthesisedType : public TypeNoBounds
326330 rust_assert (type_in_parens != nullptr );
327331 return type_in_parens;
328332 }
333+
334+ Type::Kind get_type_kind () const override
335+ {
336+ return Type::Kind::Parenthesised;
337+ }
329338};
330339
331340// Impl trait with a single bound? Poor reference material here.
@@ -361,6 +370,11 @@ class ImplTraitTypeOneBound : public TypeNoBounds
361370 {
362371 return new ImplTraitTypeOneBound (trait_bound->reconstruct (), locus);
363372 }
373+
374+ Type::Kind get_type_kind () const override
375+ {
376+ return Type::Kind::ImplTraitTypeOneBound;
377+ }
364378};
365379
366380/* A trait object with a single trait bound. The "trait bound" is really just
@@ -412,6 +426,11 @@ class TraitObjectTypeOneBound : public TypeNoBounds
412426 }
413427
414428 bool is_dyn () const { return has_dyn; }
429+
430+ Type::Kind get_type_kind () const override
431+ {
432+ return Type::Kind::TraitObjectTypeOneBound;
433+ }
415434};
416435
417436class TypePath ; // definition moved to "rust-path.h"
@@ -478,6 +497,8 @@ class TupleType : public TypeNoBounds
478497 {
479498 return new TupleType (reconstruct_vec (elems), locus);
480499 }
500+
501+ Type::Kind get_type_kind () const override { return Type::Kind::Tuple; }
481502};
482503
483504/* A type with no values, representing the result of computations that never
@@ -507,6 +528,8 @@ class NeverType : public TypeNoBounds
507528 location_t get_locus () const override final { return locus; }
508529
509530 void accept_vis (ASTVisitor &vis) override ;
531+
532+ Type::Kind get_type_kind () const override { return Type::Kind::Never; }
510533};
511534
512535// A type consisting of a pointer without safety or liveness guarantees
@@ -588,6 +611,8 @@ class RawPointerType : public TypeNoBounds
588611 {
589612 return new RawPointerType (pointer_type, type->reconstruct (), locus);
590613 }
614+
615+ Type::Kind get_type_kind () const override { return Type::Kind::RawPointer; }
591616};
592617
593618// A type pointing to memory owned by another value
@@ -682,6 +707,8 @@ class ReferenceType : public TypeNoBounds
682707 lifetime->get_locus ())
683708 : tl::nullopt );
684709 }
710+
711+ Type::Kind get_type_kind () const override { return Type::Kind::Reference; }
685712};
686713
687714// A fixed-size sequence of elements of a specified type
@@ -758,6 +785,8 @@ class ArrayType : public TypeNoBounds
758785 size /* FIXME: This should be `reconstruct_expr()` */ ,
759786 locus);
760787 }
788+
789+ Type::Kind get_type_kind () const override { return Type::Kind::Array; }
761790};
762791
763792/* A dynamically-sized type representing a "view" into a sequence of elements of
@@ -818,6 +847,8 @@ class SliceType : public TypeNoBounds
818847 {
819848 return new SliceType (elem_type->reconstruct (), locus);
820849 }
850+
851+ Type::Kind get_type_kind () const override { return Type::Kind::Slice; }
821852};
822853
823854/* Type used in generic arguments to explicitly request type inference (wildcard
@@ -851,6 +882,8 @@ class InferredType : public TypeNoBounds
851882 location_t get_locus () const override final { return locus; }
852883
853884 void accept_vis (ASTVisitor &vis) override ;
885+
886+ Type::Kind get_type_kind () const override { return Type::Kind::Inferred; }
854887};
855888
856889class QualifiedPathInType ; // definition moved to "rust-path.h"
@@ -1086,6 +1119,11 @@ class BareFunctionType : public TypeNoBounds
10861119 {
10871120 return new BareFunctionType (*this );
10881121 }
1122+
1123+ Type::Kind get_type_kind () const override
1124+ {
1125+ return Type::Kind::BareFunction;
1126+ }
10891127};
10901128
10911129// Forward decl - defined in rust-macro.h
0 commit comments