aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-11-20 01:28:04 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:32:57 +0100
commitb3246d3ff22035cff465e75ebe42ff2be4ce46d2 (patch)
treee2dd1c0236bfd6027f098f7b0c0b393ca2b378ce
parent45d4f73b81dcd26df03e5e210a1f50803d1d4733 (diff)
downloadgcc-b3246d3ff22035cff465e75ebe42ff2be4ce46d2.zip
gcc-b3246d3ff22035cff465e75ebe42ff2be4ce46d2.tar.gz
gcc-b3246d3ff22035cff465e75ebe42ff2be4ce46d2.tar.bz2
gccrs: Fix FnParam pattern location ternary logic
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 <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/rust/typecheck/rust-tyty-call.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-call.cc b/gcc/rust/typecheck/rust-tyty-call.cc
index 725b841..5fea34d 100644
--- a/gcc/rust/typecheck/rust-tyty-call.cc
+++ b/gcc/rust/typecheck/rust-tyty-call.cc
@@ -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
@@ -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 ();