Skip to content

#[contract] macro should emit compile_error guard for missing features #3

@HDauven

Description

@HDauven

Summary

When building a forge-based contract for WASM without specifying either contract or data-driver feature, the build fails with cryptic errors about missing allocator and ABI types. Users must currently add a manual compile_error! guard in each contract to get a helpful error message. (As is done in the test-bridge example) This guard should be part of the macro's generated code to eliminate boilerplate and ensure consistent developer experience across all forge-based contracts.

Possible solution design or implementation

The #[contract] macro should emit the following guard as part of its code generation:

#[cfg(all(target_family = "wasm", not(any(feature = "contract", feature = "data-driver"))))]
compile_error!("Enable either 'contract' or 'data-driver' feature for WASM builds");

This could be added in generate.rs alongside the existing #[cfg(target_family = "wasm")] blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions