diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-10-05 17:24:42 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-02-21 12:36:32 +0100 |
commit | a5d3586a9b159dd7c93992875b89605bedd0a60a (patch) | |
tree | b019a09ec6c7ad201fa8e02afd0086722c8e9d9e /gcc/rust | |
parent | 31b77593edbf623fb8f84e35baeb927fdd7c55b6 (diff) | |
download | gcc-a5d3586a9b159dd7c93992875b89605bedd0a60a.zip gcc-a5d3586a9b159dd7c93992875b89605bedd0a60a.tar.gz gcc-a5d3586a9b159dd7c93992875b89605bedd0a60a.tar.bz2 |
gccrs: Support looking up super traits for trait items
When supporting calls to super traits we need to allow lookups based on
the super traits as specified on the TraitReferences.
Fixes #1555
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-ref.h (lookup_trait_item): Add lookup
in super_trait.
gcc/testsuite/ChangeLog:
* rust/compile/torture/issue-1555.rs: New test.
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-trait-ref.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-trait-ref.h b/gcc/rust/typecheck/rust-hir-trait-ref.h index f6a3328..7eeb330 100644 --- a/gcc/rust/typecheck/rust-hir-trait-ref.h +++ b/gcc/rust/typecheck/rust-hir-trait-ref.h @@ -336,6 +336,15 @@ public: return true; } } + + // lookup super traits + for (const auto &super_trait : super_traits) + { + bool found = super_trait->lookup_trait_item (ident, ref); + if (found) + return true; + } + return false; } @@ -351,6 +360,16 @@ public: if (ident.compare (item.get_identifier ()) == 0) return &item; } + + // lookup super traits + for (const auto &super_trait : super_traits) + { + const TraitItemReference *res + = super_trait->lookup_trait_item (ident, type); + if (!res->is_error ()) + return res; + } + return &TraitItemReference::error_node (); } |