diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-07-02 20:24:43 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:49:30 +0100 |
commit | 68c4066e1afecc1781f387c00c10c9e9d6c02359 (patch) | |
tree | e3a3d5428bcf67d7e978642c56bd5c3f9a686ad8 /gcc/rust/hir/tree/rust-hir.h | |
parent | 90f6b7b56b027c229b519a17ed4bda180b54883d (diff) | |
download | gcc-68c4066e1afecc1781f387c00c10c9e9d6c02359.zip gcc-68c4066e1afecc1781f387c00c10c9e9d6c02359.tar.gz gcc-68c4066e1afecc1781f387c00c10c9e9d6c02359.tar.bz2 |
gccrs: Track fn_once output lang item properly
In order to setup the Output assoicated type we can rely on using generic
argument bindings. So for example when we have the FnOnce trait:
#[lang = "fn_once"]
pub trait FnOnce<Args> {
#[lang = "fn_once_output"]
type Output;
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}
Thn we might have a function such as:
pub fn map<R, F: FnOnce(T) -> R>(self, f: F) -> Option<R> { ... }
This trait bound predicate of FnOnce(T) -> R we setup generics for the
bound as:
FnOnce<(T), Output=R>
This means we can reuse our generic arguments handling to get this support.
Fixes #2105
gcc/rust/ChangeLog:
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): track output
* util/rust-hir-map.cc (Mappings::lookup_trait_item_lang_item): new helper
* util/rust-hir-map.h: add prototype for helper
gcc/testsuite/ChangeLog:
* rust/compile/issue-2105.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/hir/tree/rust-hir.h')
0 files changed, 0 insertions, 0 deletions