A Rust environment helper must return owned values, not references to its parameters
PitfallVerified 4 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
Compiling an isolated helper fails with E0515: cannot return value referencing function parameter, as seen in Linux helpers that read system info inside closures.
Cause#
The helper returns a reference that borrows from a closure-owned parameter.
Fix#
Return owned values, such as String.
Evidence#
Observed notes, 2026-10-03, rvow fingerprint.rs.
Also found by searching
- E0515: cannot return value referencing function parameter
- rust helper returns reference to closure parameter does not compile
- how do I return an env value from a test helper in rust