aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-03-13 17:02:56 +0000
committerPhilip Herron <philip.herron@embecosm.com>2023-03-17 10:34:36 +0000
commit75b6a14c46e9572998f88ee211ae8e8323e0ce72 (patch)
treed2bba9f14342253107d82966e92bde8238efcb74 /gcc/rust
parentdab27f737e1a2c5c071b7885de2fa73f70fccd63 (diff)
downloadgcc-75b6a14c46e9572998f88ee211ae8e8323e0ce72.zip
gcc-75b6a14c46e9572998f88ee211ae8e8323e0ce72.tar.gz
gcc-75b6a14c46e9572998f88ee211ae8e8323e0ce72.tar.bz2
gccrs: Only infer when no generic arguments have been specified
On Paths such as: mem::size_of<T>() we always specified to infer the generics which is not always the case and can cause stay inference variables. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): remove infer call (TypeCheckExpr::resolve_root_path): only infer when we need to gcc/testsuite/ChangeLog: * rust/compile/sizeof-stray-infer-var-bug.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-path.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index ac12eae..cd0c670 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -151,11 +151,6 @@ TypeCheckExpr::visit (HIR::PathInExpression &expr)
if (tyseg->get_kind () == TyTy::TypeKind::ERROR)
return;
- if (tyseg->needs_generic_substitutions ())
- {
- tyseg = SubstMapper::InferSubst (tyseg, expr.get_locus ());
- }
-
bool fully_resolved = offset == expr.get_segments ().size ();
if (fully_resolved)
{
@@ -285,6 +280,10 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
if (lookup->get_kind () == TyTy::TypeKind::ERROR)
return new TyTy::ErrorType (expr.get_mappings ().get_hirid ());
}
+ else if (lookup->needs_generic_substitutions ())
+ {
+ lookup = SubstMapper::InferSubst (lookup, expr.get_locus ());
+ }
*root_resolved_node_id = ref_node_id;
*offset = *offset + 1;