gccrs
gccrs copied to clipboard
Dynamic dispatch with supertraits
There was only one function that needed modification, the rest is testing for this new feature :)
gcc/rust/ChangeLog:
* backend/rust-compile.cc:
Modify compute_address_for_trait_item to support supertraits
* typecheck/rust-tyty.cc:
Remove auto
gcc/testsuite/ChangeLog:
* rust/compile/trait13.rs:
Add test for supertraits of supertraits
* rust/compile/trait14.rs:
Diamond problem with supertraits test
* rust/execute/torture/trait14.rs:
Add test for dynamic dispatch with supertraits
* rust/execute/torture/trait15.rs:
Add test for dynamic dispatch with generics
* rust/execute/torture/trait16.rs:
Add test for dynamic dispatch with lifetime params 1
* rust/execute/torture/trait17.rs:
Add test for dynamic dispatch with lifetime params 2
* rust/execute/torture/trait18.rs:
Add test for default implementations with dynamic dispatch and
supertraits
Fixes #914
- [x] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
- [x] Read contributing guidlines
- [x]
make check-rust
passes locally - [x] Run
clang-format
- [x] Added any relevant test cases to
gcc/testsuite/rust/
Modifies compute_address_for_trait_item to support supertraits. The algorithm works by looping over receiver_bounds for all relevant traits, and attempting to find one that matches the type, and contains the correct function implementation.