Skip to content

missing-contract-annotation never recurses into nested modules, unlike the rest of the crate #369

Description

@unrealtim-tech

Labels: bug, checks-crate
Crate: checks

Description
crates/checks/src/annotations.rs's run (lines ~24-77) collects #[contract] structs and #[contractimpl] blocks by iterating file.items directly, with no Item::Mod handling at all — unlike crate::util::contractimpl_functions_excluding_test (and its sibling), which every other check in the crate uses and which recurses into nested modules.

A #[contract] struct and its #[contractimpl] block declared inside a submodule (a common organizational pattern) are completely invisible to this check:

mod contract {
    #[contract]
    pub struct C;
    #[contractimpl]
    impl C { /* ... */ }
}

A real copy-paste mismatch (missing annotation, mismatched struct name, etc.) inside a module is never reported.

Acceptance Criteria

  • Recurse into Item::Mod when collecting both #[contract] structs and #[contractimpl] blocks, consistent with the module-aware traversal used elsewhere in the crate.
  • Add a test with a mismatched contract struct/impl pair declared inside a nested module.

Difficulty: intermediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programbugSomething isn't workingchecks-crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions