Skip to content

Commit f088817

Browse files
committed
Use as member function instead of static cast
gcc/rust/ChangeLog: * typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Use as member function. (TypeCoercionRules::coerce_borrowed_pointer): Likewise. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
1 parent 1b60b86 commit f088817

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

gcc/rust/typecheck/rust-coercion.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,14 @@ TypeCoercionRules::do_coercion (TyTy::BaseType *receiver)
8888
{
8989
case TyTy::TypeKind::POINTER:
9090
{
91-
TyTy::PointerType *ptr = static_cast<TyTy::PointerType *> (expected);
91+
auto *ptr = expected->as<TyTy::PointerType> ();
9292
try_result = coerce_unsafe_ptr (receiver, ptr, ptr->mutability ());
9393
return !try_result.is_error ();
9494
}
9595

9696
case TyTy::TypeKind::REF:
9797
{
98-
TyTy::ReferenceType *ptr
99-
= static_cast<TyTy::ReferenceType *> (expected);
98+
auto *ptr = expected->as<TyTy::ReferenceType> ();
10099
try_result
101100
= coerce_borrowed_pointer (receiver, ptr, ptr->mutability ());
102101
return !try_result.is_error ();
@@ -272,12 +271,9 @@ TypeCoercionRules::coerce_borrowed_pointer (TyTy::BaseType *receiver,
272271
{
273272
case TyTy::TypeKind::REF:
274273
{
275-
TyTy::ReferenceType *from
276-
= static_cast<TyTy::ReferenceType *> (receiver);
277-
from_mutbl = from->mutability ();
274+
from_mutbl = receiver->as<TyTy::ReferenceType> ()->mutability ();
278275
}
279276
break;
280-
281277
default:
282278
{
283279
rust_debug ("coerce_borrowed_pointer -- unify");

0 commit comments

Comments
 (0)