Add event registration via emits attribute#18
Open
moCello wants to merge 4 commits intomocello/ai-friendlinessfrom
Open
Add event registration via emits attribute#18moCello wants to merge 4 commits intomocello/ai-friendlinessfrom
moCello wants to merge 4 commits intomocello/ai-friendlinessfrom
Conversation
…tection Add #[contract(emits = [...])] for manual event registration on trait methods with default implementations. Add compile error for public &mut self methods that emit no events, suppressible with #[contract(no_event)]. Detect variable identifiers used as abi::emit() topics (warning pending proc_macro_diagnostic stabilisation).
Add #[contract(emits = [...])] to Ownable trait methods and #[contract(no_event)] to init. Add schema test verifying ownership events appear via manual registration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add manual event registration for the
#[contract]macro via three related features:#[contract(emits = [...])]— method-level attribute that declares events emitted by trait default implementations (invisible to the macro's body scanner). Events listed inemitsare included in the contract schema alongside those discovered fromabi::emit()calls.&mut selfmethods must now emit events or declare them viaemits. Use#[contract(no_event)]to suppress the check for methods likeinitthat intentionally skip emission.abi::emit()topics (likely variables whose runtime value the macro can't capture). Warning is a no-op on stable Rust pendingproc_macro_diagnosticstabilisation.Stacks on #17.