diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-17 12:47:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 12:47:04 +0000 |
commit | f8ae675c108a075012d0edb5c3cce972182803cb (patch) | |
tree | cfb985a8dbd60780144cab50e3877c5208fc8632 | |
parent | 3ab773c57c72969125220b9cedea1f85cef6c543 (diff) | |
parent | 5290a82434aa95d1c62517b2318eed80ec55f8c3 (diff) | |
download | gcc-f8ae675c108a075012d0edb5c3cce972182803cb.zip gcc-f8ae675c108a075012d0edb5c3cce972182803cb.tar.gz gcc-f8ae675c108a075012d0edb5c3cce972182803cb.tar.bz2 |
Merge #498
498: Remove HIR::TraitItemMethod, this can be represented by TraitItemFunction r=philberty a=philberty
Canonicalizing the paths of the compiler to treat functions and methods
the same way will ensure we avoid duplication.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
-rw-r--r-- | gcc/rust/backend/rust-compile-base.h | 1 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-fnparam.h | 5 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-implitem.h | 20 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-full-decls.h | 2 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-full-test.cc | 114 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-item.h | 302 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-visitor.h | 1 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.h | 6 | ||||
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive-base.h | 1 | ||||
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.h | 5 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-const-fold-base.h | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-base.h | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-implitem.h | 7 |
13 files changed, 108 insertions, 358 deletions
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index 232d5b9..ed33515 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -143,7 +143,6 @@ public: virtual void visit (HIR::ConstantItem &const_item) {} virtual void visit (HIR::StaticItem &static_item) {} virtual void visit (HIR::TraitItemFunc &item) {} - virtual void visit (HIR::TraitItemMethod &item) {} virtual void visit (HIR::TraitItemConst &item) {} virtual void visit (HIR::TraitItemType &item) {} virtual void visit (HIR::Trait &trait) {} diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h index 13bb74d..e3f9558 100644 --- a/gcc/rust/backend/rust-compile-fnparam.h +++ b/gcc/rust/backend/rust-compile-fnparam.h @@ -70,7 +70,10 @@ public: HIR::SelfParam &self, Btype *decl_type, Location locus) { - if (!self.get_is_mut ()) + bool is_immutable + = self.get_self_kind () == HIR::SelfParam::ImplicitSelfKind::IMM + || self.get_self_kind () == HIR::SelfParam::ImplicitSelfKind::IMM_REF; + if (is_immutable) decl_type = ctx->get_backend ()->immutable_type (decl_type); return ctx->get_backend ()->parameter_variable (fndecl, "self", decl_type, diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h index 4479d14..2e7d4d8 100644 --- a/gcc/rust/hir/rust-ast-lower-implitem.h +++ b/gcc/rust/hir/rust-ast-lower-implitem.h @@ -313,6 +313,7 @@ public: HIR::TraitFunctionDecl decl (ref.get_identifier (), std::move (qualifiers), std::move (generic_params), + HIR::SelfParam::error (), std::move (function_params), std::move (return_type), std::move (where_clause)); @@ -374,12 +375,12 @@ public: function_params.push_back (hir_param); } - HIR::TraitMethodDecl decl (ref.get_identifier (), std::move (qualifiers), - std::move (generic_params), - std::move (self_param), - std::move (function_params), - std::move (return_type), - std::move (where_clause)); + HIR::TraitFunctionDecl decl (ref.get_identifier (), std::move (qualifiers), + std::move (generic_params), + std::move (self_param), + std::move (function_params), + std::move (return_type), + std::move (where_clause)); HIR::Expr *block_expr = method.has_definition () ? ASTLoweringExpr::translate (method.get_definition ().get ()) @@ -391,10 +392,9 @@ public: UNKNOWN_LOCAL_DEFID); translated - = new HIR::TraitItemMethod (mapping, std::move (decl), - std::unique_ptr<HIR::Expr> (block_expr), - method.get_outer_attrs (), - method.get_locus ()); + = new HIR::TraitItemFunc (mapping, std::move (decl), + std::unique_ptr<HIR::Expr> (block_expr), + method.get_outer_attrs (), method.get_locus ()); } void visit (AST::TraitItemConst &constant) override diff --git a/gcc/rust/hir/tree/rust-hir-full-decls.h b/gcc/rust/hir/tree/rust-hir-full-decls.h index 0fa845b..ebe4bb3 100644 --- a/gcc/rust/hir/tree/rust-hir-full-decls.h +++ b/gcc/rust/hir/tree/rust-hir-full-decls.h @@ -188,8 +188,6 @@ class ConstantItem; class StaticItem; struct TraitFunctionDecl; class TraitItemFunc; -struct TraitMethodDecl; -class TraitItemMethod; class TraitItemConst; class TraitItemType; class Trait; diff --git a/gcc/rust/hir/tree/rust-hir-full-test.cc b/gcc/rust/hir/tree/rust-hir-full-test.cc index 32acefc..14b64d2 100644 --- a/gcc/rust/hir/tree/rust-hir-full-test.cc +++ b/gcc/rust/hir/tree/rust-hir-full-test.cc @@ -3599,105 +3599,11 @@ TraitFunctionDecl::as_string () const } str += "\n Function params: "; - if (has_params ()) - { - for (const auto ¶m : function_params) - { - str += "\n " + param.as_string (); - } - } - else - { - str += "none"; - } - - str += "\n Return type: "; - if (has_return_type ()) - { - str += return_type->as_string (); - } - else - { - str += "none (void)"; - } - - str += "\n Where clause: "; - if (has_where_clause ()) - { - str += where_clause.as_string (); - } - else + if (is_method ()) { - str += "none"; + str += self.as_string (); } - return str; -} - -std::string -TraitItemMethod::as_string () const -{ - std::string str = "outer attributes: "; - if (outer_attrs.empty ()) - { - str += "none"; - } - else - { - /* note that this does not print them with "outer attribute" syntax - - * just the body */ - for (const auto &attr : outer_attrs) - { - str += "\n " + attr.as_string (); - } - } - - str += "\n" + decl.as_string (); - - str += "\n Definition (block expr): "; - if (has_definition ()) - { - str += block_expr->as_string (); - } - else - { - str += "none"; - } - - return str; -} - -std::string -TraitMethodDecl::as_string () const -{ - std::string str = qualifiers.as_string () + "fn " + function_name; - - // generic params - str += "\n Generic params: "; - if (generic_params.empty ()) - { - str += "none"; - } - else - { - for (const auto ¶m : generic_params) - { - // DEBUG: null pointer check - if (param == nullptr) - { - rust_debug ( - "something really terrible has gone wrong - null pointer " - "generic param in trait function decl."); - return "nullptr_POINTER_MARK"; - } - - str += "\n " + param->as_string (); - } - } - - str += "\n Self param: " + self_param.as_string (); - - str += "\n Function params: "; if (has_params ()) { for (const auto ¶m : function_params) @@ -3820,7 +3726,7 @@ SelfParam::as_string () const // type (i.e. not ref, no lifetime) std::string str; - if (is_mut) + if (is_mut ()) { str += "mut "; } @@ -3836,7 +3742,7 @@ SelfParam::as_string () const // ref and lifetime std::string str = "&" + lifetime.as_string () + " "; - if (is_mut) + if (is_mut ()) { str += "mut "; } @@ -3845,12 +3751,12 @@ SelfParam::as_string () const return str; } - else if (has_ref) + else if (is_ref ()) { // ref with no lifetime std::string str = "&"; - if (is_mut) + if (is_mut ()) { str += " mut "; } @@ -3864,7 +3770,7 @@ SelfParam::as_string () const // no ref, no type std::string str; - if (is_mut) + if (is_mut ()) { str += "mut "; } @@ -4580,12 +4486,6 @@ TraitItemFunc::accept_vis (HIRVisitor &vis) } void -TraitItemMethod::accept_vis (HIRVisitor &vis) -{ - vis.visit (*this); -} - -void TraitItemConst::accept_vis (HIRVisitor &vis) { vis.visit (*this); diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 74969f9..73c18d5 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -305,45 +305,34 @@ public: // A self parameter in a method struct SelfParam { +public: + enum ImplicitSelfKind + { + IMM, + MUT, + IMM_REF, + MUT_REF, + NONE + }; + private: - bool has_ref; - bool is_mut; - // bool has_lifetime; // only possible if also ref + ImplicitSelfKind self_kind; Lifetime lifetime; - - // bool has_type; // only possible if not ref std::unique_ptr<Type> type; - Location locus; - Analysis::NodeMapping mappings; - // Unrestricted constructor used for error state - SelfParam (Analysis::NodeMapping mappings, Lifetime lifetime, bool has_ref, - bool is_mut, Type *type) - : has_ref (has_ref), is_mut (is_mut), lifetime (std::move (lifetime)), - type (type), mappings (mappings) + SelfParam (Analysis::NodeMapping mappings, ImplicitSelfKind self_kind, + Lifetime lifetime, Type *type) + : self_kind (self_kind), lifetime (std::move (lifetime)), type (type), + mappings (mappings) {} - // this is ok as no outside classes can ever call this public: - // Returns whether the self-param has a type field. - bool has_type () const { return type != nullptr; } - - // Returns whether the self-param has a valid lifetime. - bool has_lifetime () const { return !lifetime.is_error (); } - - // Returns whether the self-param is in an error state. - bool is_error () const - { - return has_type () && has_lifetime (); - // not having either is not an error - } - // Type-based self parameter (not ref, no lifetime) SelfParam (Analysis::NodeMapping mappings, std::unique_ptr<Type> type, bool is_mut, Location locus) - : has_ref (false), is_mut (is_mut), + : self_kind (is_mut ? ImplicitSelfKind::MUT : ImplicitSelfKind::IMM), lifetime (Lifetime (mappings, Lifetime::LifetimeType::NAMED, "", locus)), type (std::move (type)), locus (locus), mappings (mappings) {} @@ -351,13 +340,14 @@ public: // Lifetime-based self parameter (is ref, no type) SelfParam (Analysis::NodeMapping mappings, Lifetime lifetime, bool is_mut, Location locus) - : has_ref (true), is_mut (is_mut), lifetime (std::move (lifetime)), - locus (locus), mappings (mappings) + : self_kind (is_mut ? ImplicitSelfKind::MUT_REF + : ImplicitSelfKind::IMM_REF), + lifetime (std::move (lifetime)), locus (locus), mappings (mappings) {} // Copy constructor requires clone SelfParam (SelfParam const &other) - : has_ref (other.has_ref), is_mut (other.is_mut), lifetime (other.lifetime), + : self_kind (other.self_kind), lifetime (other.lifetime), locus (other.locus), mappings (other.mappings) { if (other.type != nullptr) @@ -369,8 +359,8 @@ public: { if (other.type != nullptr) type = other.type->clone_type (); - is_mut = other.is_mut; - has_ref = other.has_ref; + + self_kind = other.self_kind; lifetime = other.lifetime; locus = other.locus; mappings = other.mappings; @@ -382,14 +372,27 @@ public: SelfParam (SelfParam &&other) = default; SelfParam &operator= (SelfParam &&other) = default; + static SelfParam error () + { + return SelfParam (Analysis::NodeMapping::get_error (), + ImplicitSelfKind::NONE, Lifetime::error (), nullptr); + } + + // Returns whether the self-param has a type field. + bool has_type () const { return type != nullptr; } + + // Returns whether the self-param has a valid lifetime. + bool has_lifetime () const { return !lifetime.is_error (); } + + // Returns whether the self-param is in an error state. + bool is_error () const { return self_kind != ImplicitSelfKind::NONE; } + std::string as_string () const; Location get_locus () const { return locus; } - bool get_has_ref () const { return has_ref; }; - bool get_is_mut () const { return is_mut; } + ImplicitSelfKind get_self_kind () const { return self_kind; } - // TODO: is this better? Or is a "vis_block" better? std::unique_ptr<Type> &get_type () { rust_assert (has_type ()); @@ -397,6 +400,18 @@ public: } Analysis::NodeMapping get_mappings () { return mappings; } + + bool is_mut () const + { + return self_kind == ImplicitSelfKind::MUT + || self_kind == ImplicitSelfKind::MUT_REF; + } + + bool is_ref () const + { + return self_kind == ImplicitSelfKind::IMM_REF + || self_kind == ImplicitSelfKind::MUT_REF; + } }; // Qualifiers for function, i.e. const, unsafe, extern etc. @@ -2319,61 +2334,29 @@ public: Type *get_type () { return type.get (); } protected: - /* Use covariance to implement clone function as returning this object - * rather than base */ StaticItem *clone_item_impl () const override { return new StaticItem (*this); } - - /* Use covariance to implement clone function as returning this object - * rather than base */ - /*virtual StaticItem* clone_statement_impl() const override { - return new StaticItem(*this); - }*/ }; // Function declaration in traits struct TraitFunctionDecl { private: - // TODO: delete and replace with Function decl item? no as no body in this. FunctionQualifiers qualifiers; Identifier function_name; - - // bool has_generics; - // Generics generic_params; - std::vector<std::unique_ptr<GenericParam> > generic_params; // inlined - - // bool has_params; - // FunctionParams function_params; - std::vector<FunctionParam> function_params; // inlined - - // bool has_return_type; + std::vector<std::unique_ptr<GenericParam> > generic_params; + std::vector<FunctionParam> function_params; std::unique_ptr<Type> return_type; - - // bool has_where_clause; WhereClause where_clause; - - // should this store location info? + SelfParam self; public: - // Returns whether function decl has generic parameters. - bool has_generics () const { return !generic_params.empty (); } - - // Returns whether function decl has regular parameters. - bool has_params () const { return !function_params.empty (); } - - // Returns whether function has return type (otherwise is void). - bool has_return_type () const { return return_type != nullptr; } - - // Returns whether function has a where clause. - bool has_where_clause () const { return !where_clause.is_empty (); } - // Mega-constructor TraitFunctionDecl (Identifier function_name, FunctionQualifiers qualifiers, std::vector<std::unique_ptr<GenericParam> > generic_params, - std::vector<FunctionParam> function_params, + SelfParam self, std::vector<FunctionParam> function_params, std::unique_ptr<Type> return_type, WhereClause where_clause) : qualifiers (std::move (qualifiers)), @@ -2381,7 +2364,7 @@ public: generic_params (std::move (generic_params)), function_params (std::move (function_params)), return_type (std::move (return_type)), - where_clause (std::move (where_clause)) + where_clause (std::move (where_clause)), self (self) {} // Copy constructor with clone @@ -2389,7 +2372,7 @@ public: : qualifiers (other.qualifiers), function_name (other.function_name), function_params (other.function_params), return_type (other.return_type->clone_type ()), - where_clause (other.where_clause) + where_clause (other.where_clause), self (other.self) { generic_params.reserve (other.generic_params.size ()); for (const auto &e : other.generic_params) @@ -2406,6 +2389,7 @@ public: function_params = other.function_params; return_type = other.return_type->clone_type (); where_clause = other.where_clause; + self = other.self; generic_params.reserve (other.generic_params.size ()); for (const auto &e : other.generic_params) @@ -2419,6 +2403,26 @@ public: TraitFunctionDecl &operator= (TraitFunctionDecl &&other) = default; std::string as_string () const; + + // Returns whether function decl has generic parameters. + bool has_generics () const { return !generic_params.empty (); } + + // Returns whether function decl has regular parameters. + bool has_params () const { return !function_params.empty (); } + + // Returns whether function has return type (otherwise is void). + bool has_return_type () const { return return_type != nullptr; } + + // Returns whether function has a where clause. + bool has_where_clause () const { return !where_clause.is_empty (); } + + bool is_method () const { return !self.is_error (); } + + SelfParam &get_self () + { + rust_assert (is_method ()); + return self; + } }; // Actual trait item function declaration within traits @@ -2484,158 +2488,6 @@ protected: } }; -// Method declaration within traits -struct TraitMethodDecl -{ -private: - // TODO: delete and replace with Function decl item? no as no body. - FunctionQualifiers qualifiers; - Identifier function_name; - - // bool has_generics; - // Generics generic_params; - std::vector<std::unique_ptr<GenericParam> > generic_params; // inlined - - SelfParam self_param; - - // bool has_params; - // FunctionParams function_params; - std::vector<FunctionParam> function_params; // inlined - - // bool has_return_type; - std::unique_ptr<Type> return_type; - - // bool has_where_clause; - WhereClause where_clause; - - // should this store location info? - -public: - // Returns whether method decl has generic parameters. - bool has_generics () const { return !generic_params.empty (); } - - // Returns whether method decl has regular parameters. - bool has_params () const { return !function_params.empty (); } - - // Returns whether method has return type (otherwise is void). - bool has_return_type () const { return return_type != nullptr; } - - // Returns whether method has a where clause. - bool has_where_clause () const { return !where_clause.is_empty (); } - - // Mega-constructor - TraitMethodDecl (Identifier function_name, FunctionQualifiers qualifiers, - std::vector<std::unique_ptr<GenericParam> > generic_params, - SelfParam self_param, - std::vector<FunctionParam> function_params, - std::unique_ptr<Type> return_type, WhereClause where_clause) - : qualifiers (std::move (qualifiers)), - function_name (std::move (function_name)), - generic_params (std::move (generic_params)), - self_param (std::move (self_param)), - function_params (std::move (function_params)), - return_type (std::move (return_type)), - where_clause (std::move (where_clause)) - {} - - // Copy constructor with clone - TraitMethodDecl (TraitMethodDecl const &other) - : qualifiers (other.qualifiers), function_name (other.function_name), - self_param (other.self_param), function_params (other.function_params), - return_type (other.return_type->clone_type ()), - where_clause (other.where_clause) - { - generic_params.reserve (other.generic_params.size ()); - for (const auto &e : other.generic_params) - generic_params.push_back (e->clone_generic_param ()); - } - - ~TraitMethodDecl () = default; - - // Overloaded assignment operator with clone - TraitMethodDecl &operator= (TraitMethodDecl const &other) - { - function_name = other.function_name; - qualifiers = other.qualifiers; - self_param = other.self_param; - function_params = other.function_params; - return_type = other.return_type->clone_type (); - where_clause = other.where_clause; - - generic_params.reserve (other.generic_params.size ()); - for (const auto &e : other.generic_params) - generic_params.push_back (e->clone_generic_param ()); - - return *this; - } - - // move constructors - TraitMethodDecl (TraitMethodDecl &&other) = default; - TraitMethodDecl &operator= (TraitMethodDecl &&other) = default; - - std::string as_string () const; -}; - -// Actual trait item method declaration within traits -class TraitItemMethod : public TraitItem -{ - AST::AttrVec outer_attrs; - TraitMethodDecl decl; - std::unique_ptr<Expr> block_expr; - Location locus; - -public: - // Returns whether method has a definition or is just a declaration. - bool has_definition () const { return block_expr != nullptr; } - - TraitItemMethod (Analysis::NodeMapping mappings, TraitMethodDecl decl, - std::unique_ptr<Expr> block_expr, AST::AttrVec outer_attrs, - Location locus) - : TraitItem (mappings), outer_attrs (std::move (outer_attrs)), - decl (std::move (decl)), block_expr (std::move (block_expr)), - locus (locus) - {} - - // Copy constructor with clone - TraitItemMethod (TraitItemMethod const &other) - : TraitItem (other.mappings), outer_attrs (other.outer_attrs), - decl (other.decl), block_expr (other.block_expr->clone_expr ()), - locus (other.locus) - {} - - // Overloaded assignment operator to clone - TraitItemMethod &operator= (TraitItemMethod const &other) - { - TraitItem::operator= (other); - outer_attrs = other.outer_attrs; - decl = other.decl; - block_expr = other.block_expr->clone_expr (); - locus = other.locus; - mappings = other.mappings; - - return *this; - } - - // move constructors - TraitItemMethod (TraitItemMethod &&other) = default; - TraitItemMethod &operator= (TraitItemMethod &&other) = default; - - std::string as_string () const override; - - Location get_locus () const { return locus; } - - void accept_vis (HIRVisitor &vis) override; - - std::unique_ptr<Expr> &get_block_expr () { return block_expr; } - -protected: - // Clone function implementation as (not pure) virtual method - TraitItemMethod *clone_trait_item_impl () const override - { - return new TraitItemMethod (*this); - } -}; - // Constant item within traits class TraitItemConst : public TraitItem { diff --git a/gcc/rust/hir/tree/rust-hir-visitor.h b/gcc/rust/hir/tree/rust-hir-visitor.h index ad033b4..6b575de 100644 --- a/gcc/rust/hir/tree/rust-hir-visitor.h +++ b/gcc/rust/hir/tree/rust-hir-visitor.h @@ -123,7 +123,6 @@ public: virtual void visit (ConstantItem &const_item) = 0; virtual void visit (StaticItem &static_item) = 0; virtual void visit (TraitItemFunc &item) = 0; - virtual void visit (TraitItemMethod &item) = 0; virtual void visit (TraitItemConst &item) = 0; virtual void visit (TraitItemType &item) = 0; virtual void visit (Trait &trait) = 0; diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index 8700be8..35dc71a 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -460,6 +460,12 @@ public: return lifetime_type == NAMED && lifetime_name.empty (); } + static Lifetime error () + { + return Lifetime (Analysis::NodeMapping::get_error (), LifetimeType::NAMED, + "", Location ()); + } + std::string as_string () const override; void accept_vis (HIRVisitor &vis) override; diff --git a/gcc/rust/lint/rust-lint-marklive-base.h b/gcc/rust/lint/rust-lint-marklive-base.h index 0452917..baae9ae 100644 --- a/gcc/rust/lint/rust-lint-marklive-base.h +++ b/gcc/rust/lint/rust-lint-marklive-base.h @@ -139,7 +139,6 @@ public: virtual void visit (HIR::ConstantItem &) override {} virtual void visit (HIR::StaticItem &) override {} virtual void visit (HIR::TraitItemFunc &) override {} - virtual void visit (HIR::TraitItemMethod &) override {} virtual void visit (HIR::TraitItemConst &) override {} virtual void visit (HIR::TraitItemType &) override {} virtual void visit (HIR::Trait &) override {} diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h index 2ad0aae..f6d4b09 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -97,11 +97,6 @@ public: item.get_block_expr ()->accept_vis (*this); } - void visit (HIR::TraitItemMethod &item) override - { - item.get_block_expr ()->accept_vis (*this); - } - void visit (HIR::ImplBlock &impl) override { for (auto &&item : impl.get_impl_items ()) diff --git a/gcc/rust/typecheck/rust-hir-const-fold-base.h b/gcc/rust/typecheck/rust-hir-const-fold-base.h index d27d9ce..11eb5e4 100644 --- a/gcc/rust/typecheck/rust-hir-const-fold-base.h +++ b/gcc/rust/typecheck/rust-hir-const-fold-base.h @@ -142,7 +142,6 @@ public: virtual void visit (HIR::ConstantItem &) override {} virtual void visit (HIR::StaticItem &) override {} virtual void visit (HIR::TraitItemFunc &) override {} - virtual void visit (HIR::TraitItemMethod &) override {} virtual void visit (HIR::TraitItemConst &) override {} virtual void visit (HIR::TraitItemType &) override {} virtual void visit (HIR::Trait &) override {} diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.h b/gcc/rust/typecheck/rust-hir-type-check-base.h index 011ed66..b2b11d3 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.h +++ b/gcc/rust/typecheck/rust-hir-type-check-base.h @@ -141,7 +141,6 @@ public: virtual void visit (HIR::ConstantItem &) override {} virtual void visit (HIR::StaticItem &) override {} virtual void visit (HIR::TraitItemFunc &) override {} - virtual void visit (HIR::TraitItemMethod &) override {} virtual void visit (HIR::TraitItemConst &) override {} virtual void visit (HIR::TraitItemType &) override {} virtual void visit (HIR::Trait &) override {} diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h index 1f66e69..46fee29 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h +++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h @@ -167,12 +167,13 @@ public: // hold all the params to the fndef std::vector<std::pair<HIR::Pattern *, TyTy::BaseType *> > params; - // add the self param at the front + // add the synthetic self param at the front, this is a placeholder for + // compilation to know parameter names. The types are ignored but we reuse + // the HIR identifier pattern which requires it HIR::SelfParam &self_param = method.get_self_param (); HIR::IdentifierPattern *self_pattern = new HIR::IdentifierPattern ("self", self_param.get_locus (), - self_param.get_has_ref (), - self_param.get_is_mut (), + self_param.is_ref (), self_param.is_mut (), std::unique_ptr<HIR::Pattern> (nullptr)); context->insert_type (self_param.get_mappings (), self->clone ()); params.push_back ( |