Skip to content

Commit f721b13

Browse files
committed
gccrs: Ensure we track the const generic substitution on the param mappings
gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc: track the const generic * typecheck/rust-tyty.cc (ConstType::is_equal): finish the is_equal Signed-off-by: Philip Herron <[email protected]>
1 parent 464d86b commit f721b13

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

gcc/rust/typecheck/rust-tyty-subst.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ SubstitutionParamMapping::fill_param_ty (
163163

164164
if (type.get_kind () == TypeKind::PARAM)
165165
{
166-
// delete param;
167-
param = static_cast<ParamType *> (type.clone ());
166+
param = static_cast<BaseGeneric *> (type.clone ());
167+
}
168+
else if (type.get_kind () == TyTy::TypeKind::CONST)
169+
{
170+
param = static_cast<BaseGeneric *> (type.clone ());
168171
}
169172
else if (param->get_kind () == TypeKind::PARAM)
170173
{

gcc/rust/typecheck/rust-tyty.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "options.h"
3838
#include "rust-system.h"
3939
#include "tree.h"
40+
#include "fold-const.h"
4041
#include <string>
4142

4243
namespace Rust {
@@ -3712,9 +3713,14 @@ ConstType::is_equal (const BaseType &other) const
37123713
return false;
37133714
}
37143715

3715-
// TODO
3716+
const ConstType &rhs = static_cast<const ConstType &> (other);
3717+
if (!get_ty ()->is_equal (*rhs.get_ty ()))
3718+
return false;
37163719

3717-
return false;
3720+
tree lv = get_value ();
3721+
tree rv = rhs.get_value ();
3722+
3723+
return operand_equal_p (lv, rv, 0);
37183724
}
37193725

37203726
ConstType *

0 commit comments

Comments
 (0)