Commit cee2581
Stop #[contract] injecting alloc use-imports into caller's crate root (#117)
* Stop #[contract] injecting alloc use-imports into caller's crate root
The alloc_setup block emitted at the caller's crate root (sibling of the
contract mod) injected `use alloc::vec;`, `use alloc::vec::Vec;`, and
`use alloc::string::String;` alongside `extern crate alloc;`, gated to
non-abi-gen riscv builds in allocator modes.
These three imports are dead weight:
- They don't reach the contract mod (Rust modules don't inherit a parent
module's `use`); in-mod user code that needs Vec/String brings its own
import, which the macro already cfg-gates via use_tree_imports_alloc.
- No generated code consumes them. Every generated allocation uses fully
qualified paths already (`alloc::vec![..]`, `alloc::vec::Vec<u8>` in the
dispatch/decode/router codegen), resolved through `extern crate alloc;`.
Their only effect was polluting the caller's crate root, so contract
authors with crate-root helper code that imports Vec/String hit a
confusing E0252/E0259 pointing at the macro invocation line rather than
their own import.
Drop the three imports from both allocator arms; keep `extern crate
alloc;` (load-bearing for the qualified paths). No behavior change for any
contract that compiles today.
Verified: pvm-contract-macros test suite (171 unit + all integration +
trybuild) passes, and all 7 example-mytoken contracts build via the CLI,
including the pico-alloc and bump-alloc variants that exercise this path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Document the no-use-injection codegen convention at the emission site
Add a comment explaining why alloc_setup keeps `extern crate alloc;` but
must not inject `use alloc::...` imports, so the deleted imports aren't
reintroduced.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Retry transient null-response deploy failures in e2e cast harness
CI flaked twice on this branch with 'cast deploy failed: Error: server
returned a null response when a non-null response was expected', hitting
a different test each run (error_call, then dynamic_bytes_length +
dynamic_echo_string). A freshly started anvil-polkadot occasionally
answers a JSON-RPC request with null; retry that specific transient
error up to 3 times before failing the test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Revert "Retry transient null-response deploy failures in e2e cast harness"
This reverts commit b83acf8.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent fa53855 commit cee2581
1 file changed
Lines changed: 9 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1223 | 1223 | | |
1224 | 1224 | | |
1225 | 1225 | | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1226 | 1235 | | |
1227 | 1236 | | |
1228 | 1237 | | |
1229 | 1238 | | |
1230 | 1239 | | |
1231 | 1240 | | |
1232 | 1241 | | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | 1242 | | |
1243 | 1243 | | |
1244 | 1244 | | |
| |||
1256 | 1256 | | |
1257 | 1257 | | |
1258 | 1258 | | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | 1259 | | |
1269 | 1260 | | |
1270 | 1261 | | |
| |||
0 commit comments