diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-01-07 14:41:12 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2023-01-10 22:12:16 +0000 |
commit | ed6718d979e400cb254279e103f239a25ea92c56 (patch) | |
tree | 499c036b44ea9eaaf7e882d98365e8d52dffbb88 /gcc/rust/lex/rust-lex.cc | |
parent | 235932042738838ac9ea9f9a32656bcd609c7497 (diff) | |
download | gcc-ed6718d979e400cb254279e103f239a25ea92c56.zip gcc-ed6718d979e400cb254279e103f239a25ea92c56.tar.gz gcc-ed6718d979e400cb254279e103f239a25ea92c56.tar.bz2 |
Support associated type bound arguments
This patch adds support for the GenercArgsBinding type, where you can
specify the associated types of a trait bound using `<Foo=i32>` style
syntax. Note that the type-resolution relys on the i32 impl for Add
as type resolution will resolve the `a+a` to the core::ops::Add method
so code generation will require this to exist.
I have ameded testsuite/rust/compile/bounds.rs as this code is wrongly
creating an HIR::GenericArgs with a trait-object type and causing issues.
the parsing is still correct but we dont have the mechanism to represent
this in AST and HIR properly. I think we will need a new HIR::GenericArgs
AssociatedTypeBindingBound or something similar. We are still lacking
bounds checking during are type coercions and unifications so running this
example using an f32 will wrongly pass type checking, this will need
addressed next.
Fixes #1720
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* hir/tree/rust-hir-path.h:
* typecheck/rust-hir-path-probe.h:
* typecheck/rust-hir-trait-resolve.cc:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound):
(TypeBoundPredicate::TypeBoundPredicate):
(TypeBoundPredicate::operator=):
(TypeBoundPredicate::apply_generic_arguments):
(TypeBoundPredicateItem::get_tyty_for_receiver):
(TypeBoundPredicate::get_num_associated_bindings):
(TypeBoundPredicate::lookup_associated_type):
(TypeBoundPredicate::get_associated_type_items):
* typecheck/rust-tyty.cc (SubstitutionRef::get_mappings_from_generic_args):
(SubstitutionRef::infer_substitions):
(SubstitutionRef::solve_missing_mappings_from_this):
* typecheck/rust-tyty.h:
gcc/testsuite/ChangeLog:
* rust/compile/bounds.rs: change to use -fsyntax-only
* rust/execute/torture/issue-1720.rs: New test.
Diffstat (limited to 'gcc/rust/lex/rust-lex.cc')
0 files changed, 0 insertions, 0 deletions