Skip to content

Commit

Permalink
Fix FnParam pattern location ternary logic
Browse files Browse the repository at this point in the history
Condition was inverted, we should retrieve the locus only if we have a
pattern.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Do not
	get a reference if the pattern does not exist.
	(TypeCheckMethodCallExpr::check): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Nov 20, 2024
1 parent 26fdda1 commit 52ab325
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gcc/rust/typecheck/rust-tyty-call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,11 @@ TypeCheckCallExpr::visit (FnType &type)
if (i < type.num_params ())
{
auto &fnparam = type.param_at (i);
auto &fn_param_pattern = fnparam.get_pattern ();
BaseType *param_ty = fnparam.get_type ();
location_t param_locus
= fnparam.has_pattern ()
? mappings.lookup_location (param_ty->get_ref ())
: fn_param_pattern.get_locus ();
? fnparam.get_pattern ().get_locus ()
: mappings.lookup_location (param_ty->get_ref ());

HirId coercion_side_id = argument->get_mappings ().get_hirid ();
auto resolved_argument_type
Expand Down Expand Up @@ -375,12 +374,11 @@ TypeCheckMethodCallExpr::check (FnType &type)
location_t arg_locus = argument.get_locus ();

auto &fnparam = type.param_at (i);
HIR::Pattern &fn_param_pattern = fnparam.get_pattern ();
BaseType *param_ty = fnparam.get_type ();
location_t param_locus
= fnparam.has_pattern ()
? mappings.lookup_location (param_ty->get_ref ())
: fn_param_pattern.get_locus ();
? fnparam.get_pattern ().get_locus ()
: mappings.lookup_location (param_ty->get_ref ());

auto argument_expr_tyty = argument.get_argument_type ();
HirId coercion_side_id = argument.get_mappings ().get_hirid ();
Expand Down

0 comments on commit 52ab325

Please sign in to comment.