diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-01 21:42:19 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-01 21:42:19 +0800 |
commit | 5967b5ac48e1fcb50ce673fc96691392e2ae2692 (patch) | |
tree | 940029692aaad862eb8e92d0a79e43fdbee35042 /src/hir/hir.hpp | |
parent | d0bb03758d31dcba938e95bd2ee155bb798a9b70 (diff) | |
download | mrust-5967b5ac48e1fcb50ce673fc96691392e2ae2692.tar.gz |
HIR - Store and use annotations for CoerceUnsized (and prepare markings for other traits)
Diffstat (limited to 'src/hir/hir.hpp')
-rw-r--r-- | src/hir/hir.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp index c439960a..73e1fd95 100644 --- a/src/hir/hir.hpp +++ b/src/hir/hir.hpp @@ -128,6 +128,23 @@ struct TypeAlias typedef ::std::vector< VisEnt<::HIR::TypeRef> > t_tuple_fields; typedef ::std::vector< ::std::pair< ::std::string, VisEnt<::HIR::TypeRef> > > t_struct_fields; +/// Cache of the state of various language traits on an enum/struct +struct TraitMarkings +{ + /// There is at least one CoerceUnsized impl for this type + bool can_coerce = false; + + /// Indicates that there is at least one Deref impl + bool has_a_deref = false; + + /// Type is always unsized (i.e. contains an unsized type) + bool is_always_unsized = false; + /// Type is always sized (i.e. cannot contain any unsized types) + bool is_always_sized = false; + /// `true` if there is a Copy impl + bool is_copy = false; +}; + class Enum { public: @@ -150,6 +167,8 @@ public: GenericParams m_params; Repr m_repr; ::std::vector< ::std::pair< ::std::string, Variant > > m_variants; + + TraitMarkings m_markings; }; class Struct { @@ -170,6 +189,8 @@ public: GenericParams m_params; Repr m_repr; Data m_data; + + TraitMarkings m_markings; }; struct AssociatedType @@ -332,6 +353,7 @@ public: void post_load_update(const ::std::string& loaded_name); const ::HIR::SimplePath& get_lang_item_path(const Span& sp, const char* name) const; + const ::HIR::SimplePath& get_lang_item_path_opt(const char* name) const; const ::HIR::TypeItem& get_typeitem_by_path(const Span& sp, const ::HIR::SimplePath& path, bool ignore_crate_name=false) const; const ::HIR::Trait& get_trait_by_path(const Span& sp, const ::HIR::SimplePath& path) const; |