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.
Updates the repository to rust 2024, partially closes use-ink/ink-alliance#43
ink::topic
attribute)How It Worked (Rust 2021):
Our original macro simply borrowed the field via &$e and then called a helper (AsOption(&$e).value()), which used specialized impls or fallback traits to return an Option<&T>. Because Rust 2021 would often extend the lifetime of these temporaries implicitly, this approach worked without lifetime issues.
Stricter Lifetime Enforcement (Rust 2024):
Rust 2024 enforces lifetimes more strictly. Now, when the macro creates a temporary binding inside its block—say with
let tmp = $e;
—and then takes a reference(&tmp)
, that reference’s lifetime is limited to the block. The temporary is dropped at the end of the block, making the returned reference invalid. This “lifetime extension” no longer happens automatically, and so we see errors like “temporary value dropped while borrowed.”Current Stable‑Rust Solution and Remaining Concern:
We implement our stable‑Rust solution entirely with macro pattern matching.
Concern:
Because we’re relying solely on token matching rather than Rust’s type system, users must explicitly annotate Option literals—bare None won’t be recognized correctly, which risks ambiguity.