aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-02-04 22:53:48 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2023-04-06 10:47:21 +0200
commiteb4a61ac1babffaa03d837d32a1107ea93e85e48 (patch)
tree4bf814557c3220af75a6ec9869b490d55a02bf5f /gcc/rust
parent11150b7c05c06b5885bfc95045699baf5e5d2a34 (diff)
downloadgcc-eb4a61ac1babffaa03d837d32a1107ea93e85e48.zip
gcc-eb4a61ac1babffaa03d837d32a1107ea93e85e48.tar.gz
gcc-eb4a61ac1babffaa03d837d32a1107ea93e85e48.tar.bz2
gccrs: Add general TypeBounds checks
Existing tests are updated to use libcore copy and clone implementation. Addresses #1725 Signed-off-by: Philip Herron <herron.philip@googlemail.com> gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): ensure the bounds are checked gcc/testsuite/ChangeLog: * rust/compile/torture/intrinsics-4.rs: implement Copy trait * rust/compile/torture/intrinsics-5.rs: likewise * rust/execute/torture/atomic_load.rs: likewise * rust/execute/torture/atomic_store.rs: likewise * rust/bounds1.rs: New test.
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-unify.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc
index 072f761..415ffcd 100644
--- a/gcc/rust/typecheck/rust-unify.cc
+++ b/gcc/rust/typecheck/rust-unify.cc
@@ -124,6 +124,17 @@ UnifyRules::go ()
rust_debug ("unify::go ltype={%s} rtype={%s}", ltype->debug_str ().c_str (),
rtype->debug_str ().c_str ());
+ // check bounds
+ if (ltype->num_specified_bounds () > 0)
+ {
+ if (!ltype->bounds_compatible (*rtype, locus, true))
+ {
+ // already emitted an error
+ emit_error = false;
+ return new TyTy::ErrorType (0);
+ }
+ }
+
switch (ltype->get_kind ())
{
case TyTy::INFER: