Skip to content

Commit 1ac78d0

Browse files
committed
Give right hand type higher priority in coercions
gcc/rust/ChangeLog: * typecheck/rust-type-util.cc: Use right hand type on error. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
1 parent 522d2d3 commit 1ac78d0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

gcc/rust/typecheck/rust-type-util.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
267267
TyTy::TyWithLocation (receiver, rhs.get_locus ()), locus,
268268
true /*emit_error*/, true /*commit*/, true /*infer*/,
269269
true /*cleanup*/);
270+
if (coerced->get_kind () == TyTy::TypeKind::ERROR)
271+
{
272+
delete coerced;
273+
coerced = lhs.get_ty ();
274+
}
275+
270276
context->insert_autoderef_mappings (id, std::move (result.adjustments));
271277
return coerced;
272278
}

0 commit comments

Comments
 (0)