aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-03-10 16:19:14 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-03-10 16:50:56 +0000
commita620a228c1d79d4725efd5d6ed5f0ebe398e6787 (patch)
tree71d2b229aefdbdabb60cde3814a7e87164b9db85
parent77a49507446b67a6c207b4e4fec3639f536b9eca (diff)
downloadgcc-a620a228c1d79d4725efd5d6ed5f0ebe398e6787.zip
gcc-a620a228c1d79d4725efd5d6ed5f0ebe398e6787.tar.gz
gcc-a620a228c1d79d4725efd5d6ed5f0ebe398e6787.tar.bz2
Add missing type-checking for slice types
-rw-r--r--gcc/rust/hir/tree/rust-hir-type.h2
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc10
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.h6
3 files changed, 16 insertions, 2 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h
index 8692dfd..39bb9d2 100644
--- a/gcc/rust/hir/tree/rust-hir-type.h
+++ b/gcc/rust/hir/tree/rust-hir-type.h
@@ -668,6 +668,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
+ std::unique_ptr<Type> &get_element_type () { return elem_type; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index 9902614..6c6546b 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -600,5 +600,15 @@ TypeCheckType::visit (HIR::ArrayType &type)
TyTy::TyVar (base->get_ref ()));
}
+void
+TypeCheckType::visit (HIR::SliceType &type)
+{
+ TyTy::BaseType *base
+ = TypeCheckType::Resolve (type.get_element_type ().get ());
+ translated
+ = new TyTy::SliceType (type.get_mappings ().get_hirid (), type.get_locus (),
+ TyTy::TyVar (base->get_ref ()));
+}
+
} // namespace Resolver
} // namespace Rust
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.h b/gcc/rust/typecheck/rust-hir-type-check-type.h
index 400328c..ef5d412 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.h
@@ -120,6 +120,8 @@ public:
void visit (HIR::ArrayType &type) override;
+ void visit (HIR::SliceType &type) override;
+
void visit (HIR::ReferenceType &type) override
{
TyTy::BaseType *base
@@ -338,8 +340,8 @@ public:
binding->inherit_bounds (specified_bounds);
// When we apply these bounds we must lookup which type this binding
- // resolves to, as this is the type which will be used during resolution of
- // the block.
+ // resolves to, as this is the type which will be used during resolution
+ // of the block.
NodeId ast_node_id = binding_type_path->get_mappings ().get_nodeid ();
// then lookup the reference_node_id