Skip to content

Commit 8334e09

Browse files
committed
gccrs: allow unifications against non const types
When type resolving a function which returns a const generic for example this means its unifying the ConstType vs the the specified type so this mean unwrapping the type of the const. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): unwrap the const type Signed-off-by: Philip Herron <[email protected]>
1 parent 793fed8 commit 8334e09

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gcc/rust/typecheck/rust-unify.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ UnifyRules::go ()
266266
}
267267
}
268268

269+
if ((ltype->is<TyTy::ConstType> () || rtype->is<TyTy::ConstType> ())
270+
&& !(ltype->is<TyTy::ConstType> () && rtype->is<TyTy::ConstType> ()))
271+
{
272+
if (ltype->is<TyTy::ConstType> ())
273+
{
274+
auto const_type = static_cast<TyTy::ConstType *> (ltype);
275+
ltype = const_type->get_ty ();
276+
}
277+
else if (rtype->is<TyTy::ConstType> ())
278+
{
279+
auto const_type = static_cast<TyTy::ConstType *> (rtype);
280+
rtype = const_type->get_ty ();
281+
}
282+
}
283+
269284
switch (ltype->get_kind ())
270285
{
271286
case TyTy::INFER:

0 commit comments

Comments
 (0)