Skip to content

Commit

Permalink
chore: Fix duplicated instantiation error
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Aug 9, 2024
1 parent 99e236c commit 0fa70ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions sylvia-derive/src/contract/communication/struct_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions sylvia/tests/ui/missing_method/msgs_misused.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> {
| ^^^^^^^^^^^

0 comments on commit 0fa70ee

Please sign in to comment.