aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/hir/rust-ast-lower-implitem.h8
-rw-r--r--gcc/rust/hir/rust-ast-lower-item.h10
-rw-r--r--gcc/rust/hir/rust-ast-lower-stmt.h2
-rw-r--r--gcc/rust/hir/rust-ast-lower-type.h2
-rw-r--r--gcc/rust/hir/tree/rust-hir-full-test.cc4
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h16
-rw-r--r--gcc/rust/util/rust-common.h6
7 files changed, 30 insertions, 18 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h
index b2c7b13..563a90c 100644
--- a/gcc/rust/hir/rust-ast-lower-implitem.h
+++ b/gcc/rust/hir/rust-ast-lower-implitem.h
@@ -119,7 +119,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
HIR::Visibility vis = HIR::Visibility::create_public ();
// need
@@ -203,7 +203,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
HIR::Visibility vis = HIR::Visibility::create_public ();
// need
@@ -315,7 +315,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
std::vector<std::unique_ptr<HIR::GenericParam> > generic_params;
if (ref.has_generics ())
@@ -393,7 +393,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
std::vector<std::unique_ptr<HIR::GenericParam> > generic_params;
if (ref.has_generics ())
diff --git a/gcc/rust/hir/rust-ast-lower-item.h b/gcc/rust/hir/rust-ast-lower-item.h
index 5b4ebc5..11b3c1f 100644
--- a/gcc/rust/hir/rust-ast-lower-item.h
+++ b/gcc/rust/hir/rust-ast-lower-item.h
@@ -384,7 +384,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
HIR::Visibility vis = HIR::Visibility::create_public ();
// need
@@ -604,8 +604,14 @@ public:
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
+ auto trait_unsafety = Unsafety::Normal;
+ if (trait.is_unsafe ())
+ {
+ trait_unsafety = Unsafety::Unsafe;
+ }
+
HIR::Trait *hir_trait
- = new HIR::Trait (mapping, trait.get_identifier (), trait.is_unsafe (),
+ = new HIR::Trait (mapping, trait.get_identifier (), trait_unsafety,
std::move (generic_params),
std::move (type_param_bounds), where_clause,
std::move (trait_items), vis, trait.get_outer_attrs (),
diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h
index ee9b675..01acb39 100644
--- a/gcc/rust/hir/rust-ast-lower-stmt.h
+++ b/gcc/rust/hir/rust-ast-lower-stmt.h
@@ -329,7 +329,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
HIR::Visibility vis = HIR::Visibility::create_public ();
// need
diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h
index f5d7641..30da36d 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -138,7 +138,7 @@ public:
bool is_variadic = false;
std::vector<HIR::LifetimeParam> lifetime_params;
HIR::FunctionQualifiers qualifiers (
- HIR::FunctionQualifiers::AsyncConstStatus::NONE, false);
+ HIR::FunctionQualifiers::AsyncConstStatus::NONE, Unsafety::Normal);
std::vector<HIR::MaybeNamedParam> named_params;
for (auto &param : fntype.get_function_params ())
diff --git a/gcc/rust/hir/tree/rust-hir-full-test.cc b/gcc/rust/hir/tree/rust-hir-full-test.cc
index 5a4ff76..21130a2 100644
--- a/gcc/rust/hir/tree/rust-hir-full-test.cc
+++ b/gcc/rust/hir/tree/rust-hir-full-test.cc
@@ -667,7 +667,7 @@ Trait::as_string () const
{
std::string str = VisItem::as_string ();
- if (has_unsafe)
+ if (unsafety == Unsafety::Unsafe)
{
str += "unsafe ";
}
@@ -1989,7 +1989,7 @@ FunctionQualifiers::as_string () const
return "ERROR_MARK_STRING: async-const status failure";
}
- if (has_unsafe)
+ if (unsafety == Unsafety::Unsafe)
{
str += "unsafe ";
}
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index 4091355..570abc4 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -440,7 +440,7 @@ public:
private:
AsyncConstStatus const_status;
- bool has_unsafe;
+ Unsafety unsafety;
bool has_extern;
std::string extern_abi; // e.g. extern "C" fn() -> i32 {}
// TODO: maybe ensure that extern_abi only exists if extern exists?
@@ -448,10 +448,10 @@ private:
// should this store location info?
public:
- FunctionQualifiers (AsyncConstStatus const_status, bool has_unsafe,
+ FunctionQualifiers (AsyncConstStatus const_status, Unsafety unsafety,
bool has_extern = false,
std::string extern_abi = std::string ())
- : const_status (const_status), has_unsafe (has_unsafe),
+ : const_status (const_status), unsafety (unsafety),
has_extern (has_extern), extern_abi (std::move (extern_abi))
{
if (!this->extern_abi.empty ())
@@ -2433,7 +2433,7 @@ protected:
// Rust trait item declaration HIR node
class Trait : public VisItem
{
- bool has_unsafe;
+ Unsafety unsafety;
Identifier name;
std::vector<std::unique_ptr<GenericParam>> generic_params;
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
@@ -2464,14 +2464,14 @@ public:
Identifier get_name () const { return name; }
// Mega-constructor
- Trait (Analysis::NodeMapping mappings, Identifier name, bool is_unsafe,
+ Trait (Analysis::NodeMapping mappings, Identifier name, Unsafety unsafety,
std::vector<std::unique_ptr<GenericParam>> generic_params,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
WhereClause where_clause,
std::vector<std::unique_ptr<TraitItem>> trait_items, Visibility vis,
AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
- has_unsafe (is_unsafe), name (std::move (name)),
+ unsafety (unsafety), name (std::move (name)),
generic_params (std::move (generic_params)),
type_param_bounds (std::move (type_param_bounds)),
where_clause (std::move (where_clause)),
@@ -2480,7 +2480,7 @@ public:
// Copy constructor with vector clone
Trait (Trait const &other)
- : VisItem (other), has_unsafe (other.has_unsafe), name (other.name),
+ : VisItem (other), unsafety (other.unsafety), name (other.name),
where_clause (other.where_clause), locus (other.locus)
{
generic_params.reserve (other.generic_params.size ());
@@ -2501,7 +2501,7 @@ public:
{
VisItem::operator= (other);
name = other.name;
- has_unsafe = other.has_unsafe;
+ unsafety = other.unsafety;
where_clause = other.where_clause;
locus = other.locus;
diff --git a/gcc/rust/util/rust-common.h b/gcc/rust/util/rust-common.h
index 6c8f454..483fe17 100644
--- a/gcc/rust/util/rust-common.h
+++ b/gcc/rust/util/rust-common.h
@@ -29,6 +29,12 @@ enum Mutability
Mut
};
+enum Unsafety
+{
+ Unsafe,
+ Normal
+};
+
} // namespace Rust
#endif // RUST_COMMON