#![allow(clippy::missing_const_for_fn)]
use antigen::{antigen, presents};
#[antigen(
name = "deliberate-leak-not-documented",
category = AntigenCategory::FunctionalCorrectness,
fingerprint = r#"any_of([body_calls("forget"), body_calls("leak")])"#,
family = "resource-lifecycle-leak",
summary = "A call to an explicit-leak primitive (mem::forget / Box::leak / Vec::leak) — Drop is deliberately skipped; the witness is the documented rationale.",
references = ["https://doc.rust-lang.org/std/mem/fn.forget.html"],
)]
pub struct DeliberateLeakNotDocumented;
#[presents(DeliberateLeakNotDocumented)]
fn leak_it(s: String) {
std::mem::forget(s);
}
#[presents(DeliberateLeakNotDocumented)]
fn use_it(s: String) -> usize {
s.len()
}
fn main() {
println!("antigen resource-lifecycle example: see source for the affinity-pair.");
println!(
"Both siblings are #[presents]-marked, so audit lists both; the ordinary drop is spared by the FINGERPRINT (it doesn't bind). To read the bind/spare side by side, see antigen/tests/stdlib_family_fingerprints.rs."
);
let _ = use_it(String::from("kept"));
leak_it(String::from("leaked-on-purpose"));
}