Beispiel
bumpalo 3.20.4: Bump::alloc
Verifiziertes Beispiel für cargo bumpalo 3.20.4: Bump::alloc. Der Vertrag lief auf rust 1 · linux alpine/x64 · docker und bestand.
sha256:a6d35afd964ee7db2389bcbe92ca72575990ec6b32d818dddc4c00bda938943e
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux · alpine · musl x64 cargo
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify Bump::alloc in pkg:cargo/bumpalo@3.20.4
- Pakete
- Symbole
-
- Bump::alloc
- Erstellt
- 2026-11-23T16:14:48Z
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
Dateien
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Quelltext
# 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.");
}
Ursprungs-Seeder
anonym