Skip to content

Commit 93f82f6

Browse files
committed
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 <dev@jakubdupak.com>
1 parent 5fa6efc commit 93f82f6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

gcc/rust/typecheck/rust-tyty.cc

+8-2
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,15 @@ is_primitive_type_kind (TypeKind kind)
140140
BaseType::BaseType (HirId ref, HirId ty_ref, TypeKind kind, RustIdent ident,
141141
std::set<HirId> refs)
142142
: TypeBoundsMappings ({}), kind (kind), ref (ref), ty_ref (ty_ref),
143-
combined (refs), ident (ident), mappings (Analysis::Mappings::get ())
143+
orig_ref (ref), combined (refs), ident (ident),
144+
mappings (Analysis::Mappings::get ())
144145
{}
145146

146147
BaseType::BaseType (HirId ref, HirId ty_ref, TypeKind kind, RustIdent ident,
147148
std::vector<TypeBoundPredicate> specified_bounds,
148149
std::set<HirId> refs)
149150
: TypeBoundsMappings (specified_bounds), kind (kind), ref (ref),
150-
ty_ref (ty_ref), combined (refs), ident (ident),
151+
ty_ref (ty_ref), orig_ref (ref), combined (refs), ident (ident),
151152
mappings (Analysis::Mappings::get ())
152153
{}
153154

@@ -178,6 +179,11 @@ BaseType::set_ty_ref (HirId id)
178179
{
179180
ty_ref = id;
180181
}
182+
HirId
183+
BaseType::get_orig_ref () const
184+
{
185+
return orig_ref;
186+
}
181187

182188
bool
183189
BaseType::is_equal (const BaseType &other) const

gcc/rust/typecheck/rust-tyty.h

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class BaseType : public TypeBoundsMappings
9999
HirId get_ty_ref () const;
100100
void set_ty_ref (HirId id);
101101

102+
HirId get_orig_ref () const;
103+
102104
virtual void accept_vis (TyVisitor &vis) = 0;
103105
virtual void accept_vis (TyConstVisitor &vis) const = 0;
104106

@@ -243,6 +245,7 @@ class BaseType : public TypeBoundsMappings
243245
TypeKind kind;
244246
HirId ref;
245247
HirId ty_ref;
248+
const HirId orig_ref;
246249
std::set<HirId> combined;
247250
RustIdent ident;
248251

0 commit comments

Comments
 (0)