Skip to content

Commit

Permalink
TyTy: Store reference to type before any substitutions
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jdupak authored and philberty committed Feb 3, 2024
1 parent 39ee37b commit 22aee65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gcc/rust/typecheck/rust-tyty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ is_primitive_type_kind (TypeKind kind)
BaseType::BaseType (HirId ref, HirId ty_ref, TypeKind kind, RustIdent ident,
std::set<HirId> 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<TypeBoundPredicate> specified_bounds,
std::set<HirId> 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 ())
{}

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-tyty.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -243,6 +245,7 @@ class BaseType : public TypeBoundsMappings
TypeKind kind;
HirId ref;
HirId ty_ref;
const HirId orig_ref;
std::set<HirId> combined;
RustIdent ident;

Expand Down

0 comments on commit 22aee65

Please sign in to comment.