aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-tree.cc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-01-07 14:41:12 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2023-04-06 10:47:17 +0200
commit7eab9d18d97d0ea938c5c7194a7a82109d3a5ea6 (patch)
tree23873ba7605959b748390a45220747787b78c346 /gcc/rust/backend/rust-tree.cc
parent3f1dbb2cf8fd7d05550ccde3273a618c76cfaf5c (diff)
downloadgcc-7eab9d18d97d0ea938c5c7194a7a82109d3a5ea6.zip
gcc-7eab9d18d97d0ea938c5c7194a7a82109d3a5ea6.tar.gz
gcc-7eab9d18d97d0ea938c5c7194a7a82109d3a5ea6.tar.bz2
gccrs: 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 gcc/rust/ChangeLog: * hir/tree/rust-hir-path.h: Add const get_identifier and get_type method. * typecheck/rust-hir-path-probe.h: Use new SubstitutionArgumentMappings constructor. * typecheck/rust-hir-trait-resolve.cc: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): Do not assert failure on size mismatch anymore. (TypeBoundPredicate::TypeBoundPredicate): Use new SubstitutionArgumentMappings constructor. (TypeBoundPredicate::operator=): Likewise. (TypeBoundPredicate::apply_generic_arguments): Likewise. (TypeBoundPredicateItem::get_tyty_for_receiver): Likewise. (TypeBoundPredicate::get_num_associated_bindings): Likewise. (TypeBoundPredicate::lookup_associated_type): Fix implementation for new system. (TypeBoundPredicate::get_associated_type_items): Likewise. * typecheck/rust-tyty.cc (SubstitutionRef::get_mappings_from_generic_args): Add new behavior. (SubstitutionRef::infer_substitions): Use new constructor and add comment. (SubstitutionRef::solve_missing_mappings_from_this): Use new constructor. * typecheck/rust-tyty.h: Define new constructors. gcc/testsuite/ChangeLog: * rust/compile/bounds.rs: change to use -fsyntax-only * rust/execute/torture/issue-1720.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend/rust-tree.cc')
0 files changed, 0 insertions, 0 deletions