From 22aee650ee89eaa2cdf636fe01b46364872e14fd Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Tue, 23 Jan 2024 14:50:57 +0100 Subject: [PATCH] TyTy: Store reference to type before any substitutions gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (BaseType::BaseType): Store orig ref. (BaseType::get_orig_ref): Add getter. * typecheck/rust-tyty.h: Store orig ref. Signed-off-by: Jakub Dupak --- gcc/rust/typecheck/rust-tyty.cc | 10 ++++++++-- gcc/rust/typecheck/rust-tyty.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index ea6d17d53523..9863ed0ac7b6 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -140,14 +140,15 @@ is_primitive_type_kind (TypeKind kind) BaseType::BaseType (HirId ref, HirId ty_ref, TypeKind kind, RustIdent ident, std::set refs) : TypeBoundsMappings ({}), kind (kind), ref (ref), ty_ref (ty_ref), - combined (refs), ident (ident), mappings (Analysis::Mappings::get ()) + orig_ref (ref), combined (refs), ident (ident), + mappings (Analysis::Mappings::get ()) {} BaseType::BaseType (HirId ref, HirId ty_ref, TypeKind kind, RustIdent ident, std::vector specified_bounds, std::set refs) : TypeBoundsMappings (specified_bounds), kind (kind), ref (ref), - ty_ref (ty_ref), combined (refs), ident (ident), + ty_ref (ty_ref), orig_ref (ref), combined (refs), ident (ident), mappings (Analysis::Mappings::get ()) {} @@ -178,6 +179,11 @@ BaseType::set_ty_ref (HirId id) { ty_ref = id; } +HirId +BaseType::get_orig_ref () const +{ + return orig_ref; +} bool BaseType::is_equal (const BaseType &other) const diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 1a02bf2981de..48c58a3af59b 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -99,6 +99,8 @@ class BaseType : public TypeBoundsMappings HirId get_ty_ref () const; void set_ty_ref (HirId id); + HirId get_orig_ref () const; + virtual void accept_vis (TyVisitor &vis) = 0; virtual void accept_vis (TyConstVisitor &vis) const = 0; @@ -243,6 +245,7 @@ class BaseType : public TypeBoundsMappings TypeKind kind; HirId ref; HirId ty_ref; + const HirId orig_ref; std::set combined; RustIdent ident;