Skip to content

Commit 2c850a6

Browse files
committed
gccrs: get rid of more clones in unify path
gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::expect_reference): remove clone (UnifyRules::expect_pointer): likewise (UnifyRules::expect_slice): likewise (UnifyRules::expect_tuple): likewise (UnifyRules::expect_int): likewise (UnifyRules::expect_uint): likewise (UnifyRules::expect_float): likewise Signed-off-by: Philip Herron <[email protected]>
1 parent 12b6c93 commit 2c850a6

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

gcc/rust/typecheck/rust-unify.cc

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,7 @@ UnifyRules::expect_reference (TyTy::ReferenceType *ltype, TyTy::BaseType *rtype)
715715
return unify_error_type_node ();
716716
}
717717

718-
return new TyTy::ReferenceType (ltype->get_ref (), ltype->get_ty_ref (),
719-
TyTy::TyVar (base_resolved->get_ref ()),
720-
ltype->mutability ());
718+
return ltype;
721719
}
722720
break;
723721

@@ -787,9 +785,7 @@ UnifyRules::expect_pointer (TyTy::PointerType *ltype, TyTy::BaseType *rtype)
787785
return unify_error_type_node ();
788786
}
789787

790-
return new TyTy::PointerType (ltype->get_ref (), ltype->get_ty_ref (),
791-
TyTy::TyVar (base_resolved->get_ref ()),
792-
ltype->mutability ());
788+
return ltype;
793789
}
794790
break;
795791

@@ -983,12 +979,7 @@ UnifyRules::expect_slice (TyTy::SliceType *ltype, TyTy::BaseType *rtype)
983979
TyTy::TyWithLocation (type.get_element_type ()));
984980

985981
if (element_unify->get_kind () != TyTy::TypeKind::ERROR)
986-
{
987-
return new TyTy::SliceType (type.get_ref (), type.get_ty_ref (),
988-
type.get_ident ().locus,
989-
TyTy::TyVar (
990-
element_unify->get_ref ()));
991-
}
982+
return ltype;
992983
}
993984
break;
994985

@@ -1298,8 +1289,7 @@ UnifyRules::expect_tuple (TyTy::TupleType *ltype, TyTy::BaseType *rtype)
12981289
fields.emplace_back (unified_ty->get_ref ());
12991290
}
13001291

1301-
return new TyTy::TupleType (type.get_ref (), type.get_ty_ref (),
1302-
type.get_ident ().locus, fields);
1292+
return ltype;
13031293
}
13041294
break;
13051295

@@ -1459,8 +1449,7 @@ UnifyRules::expect_int (TyTy::IntType *ltype, TyTy::BaseType *rtype)
14591449
TyTy::IntType &type = *static_cast<TyTy::IntType *> (rtype);
14601450
bool is_valid = ltype->get_int_kind () == type.get_int_kind ();
14611451
if (is_valid)
1462-
return new TyTy::IntType (type.get_ref (), type.get_ty_ref (),
1463-
type.get_int_kind ());
1452+
return ltype;
14641453
}
14651454
break;
14661455

@@ -1518,8 +1507,7 @@ UnifyRules::expect_uint (TyTy::UintType *ltype, TyTy::BaseType *rtype)
15181507
TyTy::UintType &type = *static_cast<TyTy::UintType *> (rtype);
15191508
bool is_valid = ltype->get_uint_kind () == type.get_uint_kind ();
15201509
if (is_valid)
1521-
return new TyTy::UintType (type.get_ref (), type.get_ty_ref (),
1522-
type.get_uint_kind ());
1510+
return ltype;
15231511
}
15241512
break;
15251513

@@ -1577,8 +1565,7 @@ UnifyRules::expect_float (TyTy::FloatType *ltype, TyTy::BaseType *rtype)
15771565
TyTy::FloatType &type = *static_cast<TyTy::FloatType *> (rtype);
15781566
bool is_valid = ltype->get_float_kind () == type.get_float_kind ();
15791567
if (is_valid)
1580-
return new TyTy::FloatType (type.get_ref (), type.get_ty_ref (),
1581-
type.get_float_kind ());
1568+
return ltype;
15821569
}
15831570
break;
15841571

0 commit comments

Comments
 (0)