diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-03-17 18:09:53 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-03-18 00:15:08 +0000 |
commit | 5751556c9e6dc012ade461c04624ef9c39d1d6cf (patch) | |
tree | 68a3ff6ed1e155c00ce74be4610144da965d80e1 /gcc/rust/backend | |
parent | be27571c110d99fe55324a9c2b6622787b08fb52 (diff) | |
download | gcc-5751556c9e6dc012ade461c04624ef9c39d1d6cf.zip gcc-5751556c9e6dc012ade461c04624ef9c39d1d6cf.tar.gz gcc-5751556c9e6dc012ade461c04624ef9c39d1d6cf.tar.bz2 |
gccrs: add new apply_primtiive_type_hint to inference variables
In the senario where you infer types via unify_site_and but choose to not
commit the result you can end up with coercion to infer the result later on
which does not get fully replaced resulting in a stray inference variable
that can be left alone as a general inference variable leading to missing
type context info. This patch gives support to add type hints to inference
variables so they can be defaulted correctly in more complex cases. The
old system relied on the unification result commiting and overriding the
inference variables so they dissapear out of the current typeing context.
This was needed to fix #1981 where it is valid to inject inference
variables here. This lead to a regression in a few of the complex generic
trait test cases such as execute/torture/traits9.rs which had the wrong
argument type and defaulted wrongly to i32 instead of isize.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): fix ctor
* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
* typecheck/rust-typecheck-context.cc (TypeCheckContext::push_new_loop_context): likewise
* typecheck/rust-tyty-util.cc (TyVar::get_implicit_infer_var): likewise
* typecheck/rust-tyty.cc (InferType::InferType): new ctor with type hint
(InferType::clone): fix ctor
(InferType::apply_primitive_type_hint): new function to apply possible hint
* typecheck/rust-tyty.h: update prototypes
* typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): apply type hints
(UnifyRules::expect_bool): likewise
(UnifyRules::expect_char): likewise
(UnifyRules::expect_int): likewise
(UnifyRules::expect_uint): likewise
(UnifyRules::expect_float): likewise
(UnifyRules::expect_isize): likewise
(UnifyRules::expect_usize): likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend')
0 files changed, 0 insertions, 0 deletions