diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-02-04 22:53:48 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2023-02-05 00:10:49 +0000 |
commit | 6d7a7b22882433d46bf4e4efe8c43343892c91eb (patch) | |
tree | 61ffb34ee7ae6c32d2545dd27146fab5a8e44833 /gcc/rust | |
parent | 1b0794c172c4e60ee4cd7f2fd3a2426997b1d0a1 (diff) | |
download | gcc-6d7a7b22882433d46bf4e4efe8c43343892c91eb.zip gcc-6d7a7b22882433d46bf4e4efe8c43343892c91eb.tar.gz gcc-6d7a7b22882433d46bf4e4efe8c43343892c91eb.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.cc | 11 |
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: |