From 0fa70ee5ac6d37cbb63b2fcd32acc01a2c9be5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Fri, 9 Aug 2024 12:00:23 +0200 Subject: [PATCH] chore: Fix duplicated instantiation error --- sylvia-derive/src/contract/communication/struct_msg.rs | 7 +++++-- sylvia/tests/ui/missing_method/msgs_misused.stderr | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sylvia-derive/src/contract/communication/struct_msg.rs b/sylvia-derive/src/contract/communication/struct_msg.rs index 21717352..a353229c 100644 --- a/sylvia-derive/src/contract/communication/struct_msg.rs +++ b/sylvia-derive/src/contract/communication/struct_msg.rs @@ -47,9 +47,12 @@ impl<'a> StructMessage<'a> { ); return None; } else if variants.variants().count() > 1 { + let mut variants = variants.variants(); + let first_method = variants.next().map(|v| v.function_name()); + let obsolete = variants.next().map(|v| v.function_name()); emit_error!( - source.span(), "More than one instantiation or migration message"; - note = source.span() => "Instantiation/Migration message previously defined here" + first_method.span(), "More than one instantiation or migration message"; + note = obsolete.span() => "Instantiation/Migration message previously defined here" ); return None; } diff --git a/sylvia/tests/ui/missing_method/msgs_misused.stderr b/sylvia/tests/ui/missing_method/msgs_misused.stderr index 6d360062..0099269c 100644 --- a/sylvia/tests/ui/missing_method/msgs_misused.stderr +++ b/sylvia/tests/ui/missing_method/msgs_misused.stderr @@ -20,7 +20,7 @@ error: More than one instantiation or migration message = note: Instantiation/Migration message previously defined here - --> tests/ui/missing_method/msgs_misused.rs:35:5 + --> tests/ui/missing_method/msgs_misused.rs:31:12 | -35 | #[sv::msg(instantiate)] - | ^ +31 | pub fn instantiate(&self, ctx: InstantiateCtx) -> StdResult { + | ^^^^^^^^^^^