When we do generic argument substitution we creating mappings of the
HIR::GenericArgs argument to the TyTy::SubstitutionParam as a pointer. So
for example when we have Generic Parameters <Self, T> and arguments <T, U>
T0: Arguments: <Self=T, T=U>
T1: Self -> replaced-with T
T2: Arguments: <T=T, T=U>
T3: T maps back to the replace Self->T
T4: Arguments <T=T, T=T>
Which is wrong but because we do a string comparison to find the argument
mapping we cant reply on the pointer to the origin parameter mapping as
the parameter will be updated resulting in bad mappings.
This patch changes the Argument mappings to track the _original_ parameter
type so that lookup's for the mappings use this symbol instead not the
updated ones during substitution.
Addresses #1893
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments):
simplify lookup of the respective predicate
* typecheck/rust-tyty-subst.cc (SubstitutionArg::SubstitutionArg): track original parameter
(SubstitutionArg::operator=): update copy ctor
(SubstitutionArg::get_param_ty): use original param
(SubstitutionArg::as_string): update as_string
* typecheck/rust-tyty-subst.h: add new private field
Signed-off-by: Philip Herron <herron.philip@googlemail.com>