샘플
bumpalo 3.20.4: Bump::alloc
검증된 샘플 — cargo bumpalo 3.20.4: Bump::alloc. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Bump::alloc allocates primitives and structs in the…
sha256:a6d35afd964ee7db2389bcbe92ca72575990ec6b32d818dddc4c00bda938943e
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux · alpine · musl x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-23 |
케이스
HOW- 목표
- verify Bump::alloc in pkg:cargo/bumpalo@3.20.4
- 패키지
- 심벌
-
- Bump::alloc
- 생성일
- 2026-11-23T16:14:48Z
컨트랙트
- Bump::alloc allocates primitives and structs in the arena and returns mutable references that can be mutated in place
- Multiple concurrent Bump::alloc calls return distinct, non-overlapping mutable references
- Bump::alloc respects alignment guarantees for over-aligned types and zero-sized types
- Bump::alloc grows across chunk boundaries while preserving previously allocated values
- Bump::alloc does not invoke Drop when the Bump arena is dropped
- Bump::reset allows reusing the arena for subsequent Bump::alloc calls
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
소스
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bumpalo"
version = "3.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
[[package]]
name = "sample-bumpalo-alloc"
version = "0.1.0"
dependencies = [
"bumpalo",
]
[package]
name = "sample-bumpalo-alloc"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
bumpalo = "=3.20.4"
[[bin]]
name = "contract"
path = "test/contract.rs"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify Bump::alloc in pkg:cargo/bumpalo@3.20.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/bumpalo@3.20.4
Demonstrate these symbols/APIs:
- Bump::alloc
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:24ab68748217e6a0a8213d14bc153ca7bc3552f333edf95bb87d8dc2ea836413","contract":["Bump::alloc allocates primitives and structs in the arena and returns mutable references that can be mutated in place","Multiple concurrent Bump::alloc calls return distinct, non-overlapping mutable references","Bump::alloc respects alignment guarantees for over-aligned types and zero-sized types","Bump::alloc grows across chunk boundaries while preserving previously allocated values","Bump::alloc does not invoke Drop when the Bump arena is dropped","Bump::reset allows reusing the arena for subsequent Bump::alloc calls"],"goal":"verify Bump::alloc in pkg:cargo/bumpalo@3.20.4","kind":"HOW","packages":["pkg:cargo/bumpalo@3.20.4"],"schemaVersion":1,"symbols":["Bump::alloc"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/bumpalo@3.20.4"],"schemaVersion":1,"subject":"pkg:cargo/bumpalo@3.20.4","symbols":["Bump::alloc"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify Bump::alloc in pkg:cargo/bumpalo@3.20.4",
"kind": "HOW",
"packages": [
"pkg:cargo/bumpalo@3.20.4"
],
"symbols": [
"Bump::alloc"
]
}
//! Clean-room verification sample for `bumpalo::Bump::alloc`.
pub use bumpalo::Bump;
use std::cell::Cell;
use std::mem::align_of;
use std::ptr;
use bumpalo::Bump;
#[derive(Debug, PartialEq, Eq)]
struct Record {
id: u32,
tag: &'static str,
}
#[repr(align(32))]
#[derive(Debug, PartialEq, Eq)]
struct Aligned32([u64; 4]);
#[derive(Debug, PartialEq, Eq)]
struct ZeroSized;
struct DropTracker<'a>(&'a Cell<usize>);
impl Drop for DropTracker<'_> {
fn drop(&mut self) {
self.0.set(self.0.get() + 1);
}
}
fn main() {
// 1. Allocate primitives and structs and mutate in place via returned &mut T
let bump = Bump::new();
let num: &mut i32 = bump.alloc(41);
assert_eq!(*num, 41);
*num += 1;
assert_eq!(*num, 42);
let rec: &mut Record = bump.alloc(Record {
id: 7,
tag: "alpha",
});
assert_eq!(rec.id, 7);
assert_eq!(rec.tag, "alpha");
rec.id = 99;
rec.tag = "beta";
assert_eq!(*rec, Record { id: 99, tag: "beta" });
// 2. Multiple concurrent mutable allocations are disjoint and preserve values
let a: &mut u64 = bump.alloc(100);
let b: &mut u64 = bump.alloc(200);
assert!(!ptr::eq(a as *const u64, b as *const u64));
*a += 5;
*b += 10;
assert_eq!(*a, 105);
assert_eq!(*b, 210);
assert_eq!(*num, 42);
// 3. Over-aligned types and zero-sized types respect type alignment guarantees
let aligned: &mut Aligned32 = bump.alloc(Aligned32([1, 2, 3, 4]));
let aligned_addr = (aligned as *const Aligned32) as usize;
assert_eq!(aligned_addr % align_of::<Aligned32>(), 0);
assert_eq!(aligned.0, [1, 2, 3, 4]);
let zst: &mut ZeroSized = bump.alloc(ZeroSized);
let zst_addr = (zst as *const ZeroSized) as usize;
assert_ne!(zst_addr, 0);
assert_eq!(zst_addr % align_of::<ZeroSized>(), 0);
assert_eq!(*zst, ZeroSized);
// 4. Allocations crossing chunk boundaries grow the arena without invalidating earlier values
let mut refs: Vec<&mut [u64; 128]> = Vec::new();
for i in 0u64..16 {
let block = bump.alloc([i; 128]);
refs.push(block);
}
for (i, block) in refs.iter().enumerate() {
assert_eq!(block[0], i as u64);
assert_eq!(block[127], i as u64);
}
assert!(bump.allocated_bytes() >= 16 * 128 * 8);
// 5. Bump::alloc does not run Drop when the arena is dropped
let drops = Cell::new(0usize);
{
let drop_bump = Bump::new();
let _tracked = drop_bump.alloc(DropTracker(&drops));
}
assert_eq!(drops.get(), 0);
// 6. Arena supports reset and subsequent fresh allocations
let mut reusable = Bump::new();
{
let first = reusable.alloc(1234u32);
assert_eq!(*first, 1234);
}
reusable.reset();
let second = reusable.alloc(5678u32);
assert_eq!(*second, 5678);
println!("All Bump::alloc contract assertions passed.");
}
오리진 시더
익명