Skip to content

Module needs same name as struct #6

@Neotamandua

Description

@Neotamandua

When defining a contract module in a separate file and using #[contract] in lib.rs like:

#[contract]
pub mod counter

The code will not compile, if the file name is different from the struct. A mismatch between module name and struct name triggers a proc-macro panic with the following error:

proc-macro panicked: called `Option::unwrap()` on a `None` value

To Reproduce

  1. Take the README example code
  2. Move the module content of counter to a new file named counter.rs.
  3. Rename counter.rs to contract.rs
  4. Update lib.rs to use pub mod contract.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions