CodeSampleX

Sample

proc-macro2 1.0.107

Verified sample for cargo proc-macro2 1.0.107. The contract ran on rust 1 · linux alpine/x64 · docker and passed: proc_macro2::TokenStream parses Rust tokens…

sha256:82032eef51cea1baf7ee42a8a62989935cd2f715100253e9c239d51591e7ae0a

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux · alpine · musl x64 cargo

Verification-run environments

Environment Contract Stages Run
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-09-14

Case

HOW
Goal
verify pkg:cargo/proc-macro2@1.0.107
Packages
Created
2026-09-14T06:30:35Z

Contract

  1. proc_macro2::TokenStream parses Rust tokens from string and converts back to string
  2. proc_macro2::Ident constructs valid and raw identifiers with Span::call_site
  3. proc_macro2::Literal constructs string, integer, char, and byte string literals
  4. proc_macro2::Group constructs delimited groups and preserves Delimiter type
  5. proc_macro2::Punct constructs punctuation tokens with specified Spacing

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Download the source artifact (tar.gz)

Source

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
 "unicode-ident",
]

[[package]]
name = "proc-macro2-verify"
version = "0.1.0"
dependencies = [
 "proc-macro2",
]

[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
Cargo.toml
[package]
name = "proc-macro2-verify"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
path = "src/lib.rs"

[[bin]]
name = "contract"
path = "test/contract.rs"

[dependencies]
proc-macro2 = "=1.0.107"
PROMPT.md
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 pkg:cargo/proc-macro2@1.0.107
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/proc-macro2@1.0.107

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.
csx.json
{"case":{"caseId":"case:sha256:c8c7d7aee152b77354839a9154d90707c2ea266c2834ec3258b895362f95711f","contract":["proc_macro2::TokenStream parses Rust tokens from string and converts back to string","proc_macro2::Ident constructs valid and raw identifiers with Span::call_site","proc_macro2::Literal constructs string, integer, char, and byte string literals","proc_macro2::Group constructs delimited groups and preserves Delimiter type","proc_macro2::Punct constructs punctuation tokens with specified Spacing"],"goal":"verify pkg:cargo/proc-macro2@1.0.107","kind":"HOW","packages":["pkg:cargo/proc-macro2@1.0.107"],"schemaVersion":1},"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/proc-macro2@1.0.107"],"schemaVersion":1,"subject":"pkg:cargo/proc-macro2@1.0.107","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/proc-macro2@1.0.107",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/proc-macro2@1.0.107"
  ]
}
src/lib.rs
use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream};
use std::str::FromStr;

/// Parse a string into a TokenStream.
pub fn parse_tokens(input: &str) -> Result<TokenStream, proc_macro2::LexError> {
    TokenStream::from_str(input)
}

/// Create a new identifier.
pub fn create_ident(name: &str) -> Ident {
    Ident::new(name, Span::call_site())
}

/// Create a new raw identifier.
pub fn create_raw_ident(name: &str) -> Ident {
    Ident::new_raw(name, Span::call_site())
}

/// Create a string literal.
pub fn create_string_literal(value: &str) -> Literal {
    Literal::string(value)
}

/// Create an unsuffixed u64 literal.
pub fn create_u64_literal(value: u64) -> Literal {
    Literal::u64_unsuffixed(value)
}

/// Create a character literal.
pub fn create_char_literal(value: char) -> Literal {
    Literal::character(value)
}

/// Create a byte string literal.
pub fn create_byte_string_literal(value: &[u8]) -> Literal {
    Literal::byte_string(value)
}

/// Wrap a token stream in delimiters (e.g. parenthesis, braces).
pub fn wrap_in_group(delimiter: Delimiter, stream: TokenStream) -> Group {
    Group::new(delimiter, stream)
}

/// Create a punctuation token with spacing.
pub fn create_punct(ch: char, spacing: Spacing) -> Punct {
    Punct::new(ch, spacing)
}
test/contract.rs
use proc_macro2::{Delimiter, Spacing};
use proc_macro2_verify::{
    create_byte_string_literal, create_char_literal, create_ident, create_punct,
    create_raw_ident, create_string_literal, create_u64_literal, parse_tokens, wrap_in_group,
};

fn main() {
    // 1. proc_macro2::TokenStream parses Rust tokens from string and converts back to string
    let parsed = parse_tokens("fn hello_world() { let x = 42; }").expect("must parse valid code");
    assert!(!parsed.is_empty(), "parsed token stream must not be empty");
    let serialized = parsed.to_string();
    assert!(serialized.contains("fn"), "serialized output must contain keyword fn");
    assert!(serialized.contains("hello_world"), "serialized output must contain ident hello_world");
    assert!(serialized.contains("42"), "serialized output must contain literal 42");

    // Invalid syntax should fail lexing
    let invalid = parse_tokens("\"unclosed string literal");
    assert!(invalid.is_err(), "unclosed string must produce LexError");

    // 2. proc_macro2::Ident constructs valid and raw identifiers with Span::call_site
    let ident = create_ident("my_function");
    assert_eq!(ident.to_string(), "my_function");

    let raw_ident = create_raw_ident("match");
    assert_eq!(raw_ident.to_string(), "r#match");

    // 3. proc_macro2::Literal constructs string, integer, char, and byte string literals
    let str_lit = create_string_literal("hello \"world\"");
    assert_eq!(str_lit.to_string(), "\"hello \\\"world\\\"\"");

    let int_lit = create_u64_literal(12345);
    assert_eq!(int_lit.to_string(), "12345");

    let char_lit = create_char_literal('z');
    assert_eq!(char_lit.to_string(), "'z'");

    let bytes_lit = create_byte_string_literal(b"abc");
    assert_eq!(bytes_lit.to_string(), "b\"abc\"");

    // 4. proc_macro2::Group constructs delimited groups and preserves Delimiter type
    let inner_stream = parse_tokens("a + b").expect("must parse inner stream");
    let paren_group = wrap_in_group(Delimiter::Parenthesis, inner_stream.clone());
    assert_eq!(paren_group.delimiter(), Delimiter::Parenthesis);
    assert_eq!(paren_group.stream().to_string(), inner_stream.to_string());

    let brace_group = wrap_in_group(Delimiter::Brace, inner_stream);
    assert_eq!(brace_group.delimiter(), Delimiter::Brace);

    // 5. proc_macro2::Punct constructs punctuation tokens with specified Spacing
    let punct_alone = create_punct(';', Spacing::Alone);
    assert_eq!(punct_alone.as_char(), ';');
    assert_eq!(punct_alone.spacing(), Spacing::Alone);

    let punct_joint = create_punct(':', Spacing::Joint);
    assert_eq!(punct_joint.as_char(), ':');
    assert_eq!(punct_joint.spacing(), Spacing::Joint);

    println!("Contract verification succeeded.");
}

Origin Seeder

anonymous