diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-10-25 18:15:10 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-10-27 10:26:32 +0100 |
commit | 1a8479839e944fa2a8abd5923b4b65ce6cc96401 (patch) | |
tree | 83c5fdca56f26f64346ff103bfcd06f3c8205687 /gcc | |
parent | 1a9746032345e1bffeb9ff2c92473bf90f843379 (diff) | |
download | gcc-1a8479839e944fa2a8abd5923b4b65ce6cc96401.zip gcc-1a8479839e944fa2a8abd5923b4b65ce6cc96401.tar.gz gcc-1a8479839e944fa2a8abd5923b4b65ce6cc96401.tar.bz2 |
Remove assertion for has_where_clause
This assertion doesn't protect against bad pointers or behaviour, when we
access the where clause it is simply a wrapper over a vector of where
clause items so we can safely iterate even when the where clause item
vector is empty.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-item.h | 66 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-item.h | 21 |
2 files changed, 22 insertions, 65 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index fb7cc17..323548a 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -887,11 +887,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } Identifier get_method_name () const { return method_name; } @@ -1587,11 +1583,7 @@ public: Identifier get_function_name () const { return function_name; } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } // TODO: is this better? Or is a "vis_block" better? std::unique_ptr<Type> &get_return_type () @@ -1719,11 +1711,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } // TODO: is this better? Or is a "vis_block" better? std::unique_ptr<Type> &get_type_aliased () @@ -1789,11 +1777,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } Identifier get_identifier () const { return struct_name; } @@ -2410,11 +2394,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } protected: /* Use covariance to implement clone function as returning this object @@ -2520,11 +2500,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } Identifier get_identifier () const { return union_name; } @@ -2877,11 +2853,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } }; // Actual trait item function declaration within traits @@ -3104,11 +3076,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } SelfParam &get_self_param () { return self_param; } const SelfParam &get_self_param () const { return self_param; } @@ -3542,11 +3510,7 @@ public: return type_param_bounds; } - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } void insert_implict_self (std::unique_ptr<AST::GenericParam> &¶m) { @@ -3619,11 +3583,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } // TODO: is this better? Or is a "vis_block" better? std::unique_ptr<Type> &get_type () @@ -4270,11 +4230,7 @@ public: } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } // TODO: is this better? Or is a "vis_block" better? std::unique_ptr<Type> &get_return_type () diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index de067e6..4fdd764 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -340,6 +340,15 @@ public: bool is_empty () const { return where_clause_items.empty (); } std::string as_string () const; + + std::vector<std::unique_ptr<WhereClauseItem>> &get_items () + { + return where_clause_items; + } + const std::vector<std::unique_ptr<WhereClauseItem>> &get_items () const + { + return where_clause_items; + } }; // A self parameter in a method @@ -1205,11 +1214,7 @@ public: Identifier get_function_name () const { return function_name; } // TODO: is this better? Or is a "vis_block" better? - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } bool has_return_type () const { return return_type != nullptr; } @@ -1322,11 +1327,7 @@ public: return generic_params; } - WhereClause &get_where_clause () - { - rust_assert (has_where_clause ()); - return where_clause; - } + WhereClause &get_where_clause () { return where_clause; } std::unique_ptr<Type> &get_type_aliased () { |