Exemplo
proc-macro2 1.0.107
Amostra verificada para cargo proc-macro2 1.0.107. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou: proc_macro2::TokenStream parses Rust…
sha256:82032eef51cea1baf7ee42a8a62989935cd2f715100253e9c239d51591e7ae0a
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux · alpine · musl x64 cargo
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:cargo/proc-macro2@1.0.107
- Pacotes
- Criado
- 2026-09-14T06:30:35Z
Contrato
- 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
Arquivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Código-fonte
# 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"
[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"
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.
{"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"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/proc-macro2@1.0.107",
"kind": "HOW",
"packages": [
"pkg:cargo/proc-macro2@1.0.107"
]
}
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)
}
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.");
}
Seeder de origem
anônimo