diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-07-02 20:24:43 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-07-02 22:13:45 +0000 |
commit | b49a9581d559827de70196de0c1cad135e70e542 (patch) | |
tree | fabea3b2ea301fd33cb462191716e1e7c3c65132 /gcc/rust/resolve/rust-ast-resolve-expr.cc | |
parent | cfc51d46fcdb70bde84f030557c96866f3b18e23 (diff) | |
download | gcc-b49a9581d559827de70196de0c1cad135e70e542.zip gcc-b49a9581d559827de70196de0c1cad135e70e542.tar.gz gcc-b49a9581d559827de70196de0c1cad135e70e542.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/resolve/rust-ast-resolve-expr.cc')
0 files changed, 0 insertions, 0 deletions