[framework] Make Option public#20236
Merged
Merged
Conversation
rahxephon89
force-pushed
the
teng/make-option-public
branch
from
July 17, 2026 17:43
2a2cbac to
4fba53e
Compare
rahxephon89
marked this pull request as ready for review
July 17, 2026 17:45
rahxephon89
force-pushed
the
teng/make-option-public
branch
from
July 17, 2026 19:21
4fba53e to
b9af700
Compare
rahxephon89
force-pushed
the
teng/make-option-public
branch
from
July 17, 2026 19:54
b9af700 to
2cb4ff9
Compare
rahxephon89
force-pushed
the
teng/make-option-public
branch
from
July 20, 2026 17:51
2cb4ff9 to
c254b68
Compare
GotenJBZ
reviewed
Jul 20, 2026
georgemitenkov
approved these changes
Jul 21, 2026
rahxephon89
enabled auto-merge (squash)
July 21, 2026 14:03
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
vineethk
approved these changes
Jul 21, 2026
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
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.



Description
Makes
std::option::Optionapublic enum, using the struct/enum visibility feature introduced in Move 2.4.Today, code outside
stdmust go through theoption::some()/option::none()/option::borrow()API. With this change, any module can useOptiondirectly as an enum:Option::Some { e: x },Option::Noneis:o is Option::Somematch (o) { Option::Some { e } => ..., Option::None => ... }o.eaptos-move/framework/cached-packages/src/head.mrbis regenerated (viascripts/cargo_build_aptos_cached_packages.sh) so the releasedstd::optionbytecode carries the public visibility and the compiler-generated cross-module accessor functions.How Has This Been Tested?
test_public_option_cross_module(aptos-move/e2e-move-tests/src/tests/public_option.rs): publishes an inline Move package at0xcafe(compiled with language version 2.4+) whose entry functions exercise, from outsidestd:Some/Noneconstruction and equality withoption::some()/option::none()isoperator on both variantsmatchby value and by references.e)std::optionAPI (is_some,extract,fill,is_none) over a user-defined struct element typepublic_struct_argssuite (10 tests) passes against the regeneratedhead.mrb, confirming the special vector-based transaction-argument handling ofOptionis unaffected.Key Areas to Review
publicvisibility can never be narrowed on upgrade. This permanently freezes the variant names (Some,None) and the field name (e) as part of the public API surface ofstd::option.head.mrbmust ship together with the source change: cross-module enum operations compile into calls to accessor functions generated in the defining module, so the on-chainstd::optionbytecode must include them.Type of Change
Which Components or Systems Does This Change Impact?
🤖 Generated with Claude Code
Note
Medium Risk
Public enum visibility is irreversible on upgrade and locks variant/field names as framework API; impact is limited to Move stdlib surface and new direct enum usage patterns.
Overview
Makes
std::option::Optionapublic enum(Move 2.4+), so modules outsidestdcan useOptiondirectly instead of only theoption::some()/none()helpers.Callers can construct
Option::Some { e }/Option::None, useis,match, and read or mutate theefield onSome. Cross-module field access onNonestill fails at runtime withSTRUCT_VARIANT_MISMATCH(failure attributed to0x1::option).Adds e2e coverage
test_public_option_cross_modulethat publishes a package at0xcafeand exercises construction, matching, field access, std API interop, and the unhappy paths above.Reviewed by Cursor Bugbot for commit f6b681a. Bugbot is set up for automated code reviews on this repo. Configure here.