diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-26 14:05:03 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-03-26 16:19:07 +0000 |
commit | 65574f04d69a922eac21308f09d794fc8fab6a8c (patch) | |
tree | a93e80ae23c36d8880be5cb712ed423f9ffdc9a8 /gcc/rust/backend/rust-compile-base.h | |
parent | 46ed038945beeaf0ec44d4358070dffb08e65772 (diff) | |
download | gcc-65574f04d69a922eac21308f09d794fc8fab6a8c.zip gcc-65574f04d69a922eac21308f09d794fc8fab6a8c.tar.gz gcc-65574f04d69a922eac21308f09d794fc8fab6a8c.tar.bz2 |
gccrs: fix unconstrained infer vars on generic associated type
The trick here is that when Bar::test is resolved it resolves to the
trait method:
fn <Bar<i32>, T> (placeholder) -> placeholder
Which is fine so we need to setup the associated types for Bar<i32> which
means looking up the associated impl block then setting up the projection
of A = T so it becomes:
fn <Bar<i32>, T> (placeholder: projection<T>:T)
-> placeholder: projection<T>:T
But previously it was auto injecting inference variables so it became:
fn <Bar<i32>, T> (placeholder: projection<T>:?T)
-> placeholder: projection<T>:?T
The issue is that the binding of the generics was still T so this caused
inference variables to be injected again but unlinked. A possible tweak
would be that we are substituting again with new infer vars to actually
just unify them enplace so they are all part of the chain. This still
might be needed but lets hold off for now.
So basically when we are Path probing we dont allow GAT's to generate new
inference vars because they wont be bound to this current segment which
just causes confusion.
Fixes Rust-GCC#3242
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.h: add default infer arg
* typecheck/rust-hir-trait-resolve.cc: dont add new infer vars
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): dont infer
gcc/testsuite/ChangeLog:
* rust/compile/issue-3242.rs: no longer skip the test
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-base.h')
0 files changed, 0 insertions, 0 deletions