Skip to content

Commit afa3fb9

Browse files
Add migration docs for functional changes to cfg attributes and export args (#1886)
### What Add migration docs for #1871 and #1876 ### Why Both of these changes could impact existing contracts. The documentation provides guidance about how to migrate. ### Known limitations None --------- Co-authored-by: Leigh <351529+leighmcculloch@users.noreply.github.com>
1 parent a284918 commit afa3fb9

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

soroban-sdk/src/_migrating.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
//! passed to [`bytes!`] or [`bytesn!`] in hex or binary form (e.g. `bytes!(&env, 1)` becomes
66
//! `bytes!(&env, 0x1)`). Array literals such as `bytes!(&env, [3, 2, 1])` are unaffected.
77
//!
8+
//! 2. [The `export` argument is deprecated under the `experimental_spec_shaking_v2`
9+
//! feature][v27_export]. Under spec shaking v2 the final spec is determined by
10+
//! reachability from the contract boundary, so `export` no longer has any effect on
11+
//! [`contracttype`], [`contracterror`], or [`contractevent`] and now emits a deprecation
12+
//! warning. Remove `export = ...` from these annotations; it will be removed entirely in a
13+
//! future release. Default (v1) builds are unaffected.
14+
//!
815
//! [`bytes!`]: crate::bytes
916
//! [`bytesn!`]: crate::bytesn
17+
//! [`contracttype`]: crate::contracttype
18+
//! [`contracterror`]: crate::contracterror
19+
//! [`contractevent`]: crate::contractevent
1020
//!
1121
//! # Migrating from v25 to v26
1222
//!
@@ -333,3 +343,4 @@ pub mod v25_event_testing;
333343
pub mod v25_poseidon;
334344
pub mod v25_resource_limits;
335345
pub mod v27_bytes_literals;
346+
pub mod v27_export;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//! The `export` argument is deprecated under the [`experimental_spec_shaking_v2`] feature.
2+
//!
3+
//! The `export` argument on [`contracttype`], [`contracterror`], and [`contractevent`] controls
4+
//! whether a type contributes a contract spec entry. Under spec shaking v1 (the default), it is a
5+
//! retention hint: `export = false` suppresses the entry, hiding the type from the contract spec,
6+
//! and `export = true` forces one to be emitted.
7+
//!
8+
//! Under spec shaking v2, the final spec is instead determined by *reachability* from the contract
9+
//! boundary. The macros emit a spec entry and a marker for every type, and post-build tooling
10+
//! removes the entries for types that are not reachable from any public contract function. As a
11+
//! result, `export` no longer has any effect: it cannot hide a type that remains reachable from a
12+
//! public boundary (the entry is kept regardless), and it is redundant for a type that is already
13+
//! reachable. Worse, `export = false` can conflict with exact spec shaking by dropping a marker
14+
//! for an entry that is still reachable, leading to missing coverage.
15+
//!
16+
//! Setting `export` therefore now emits a deprecation warning at the macro call site, and the
17+
//! argument will be removed entirely in a future release. Default (v1) builds are unaffected.
18+
//!
19+
//! ## Migrating
20+
//!
21+
//! Remove the `export` argument from `contracttype`, `contracterror`, and `contractevent`
22+
//! annotations. A type that was hidden with `export = false` is filtered from the spec
23+
//! automatically when it is unused, and a type that was forced in with `export = true` is included
24+
//! whenever it is reachable.
25+
//!
26+
//! For example, a type used only inside a contract — never at a function boundary — was previously
27+
//! hidden from the spec with `export = false`:
28+
//!
29+
//! ```
30+
//! use soroban_sdk::contracttype;
31+
//!
32+
//! #[contracttype(export = false)] // 👈 👀 hint to hide the unused type from the spec
33+
//! pub struct InternalState {
34+
//! pub counter: u32,
35+
//! }
36+
//! # fn main() {}
37+
//! ```
38+
//!
39+
//! Under spec shaking v2, drop the argument. Because `InternalState` is never reachable from a
40+
//! public contract function, post-build tooling strips its spec entry automatically:
41+
//!
42+
//! ```
43+
//! use soroban_sdk::contracttype;
44+
//!
45+
//! #[contracttype] // 👈 👀 no export argument; reachability determines the final spec
46+
//! pub struct InternalState {
47+
//! pub counter: u32,
48+
//! }
49+
//! # fn main() {}
50+
//! ```
51+
//!
52+
//! [`contracttype`]: crate::contracttype
53+
//! [`contracterror`]: crate::contracterror
54+
//! [`contractevent`]: crate::contractevent
55+
//! [`experimental_spec_shaking_v2`]: crate::_features#experimental_spec_shaking_v2

0 commit comments

Comments
 (0)