Report #73842
[bug\_fix] use of moved value: \`s\` \(E0382\)
Clone the data with \`s.clone\(\)\` if the performance cost is acceptable, change the function signature to accept a reference \`&String\` or \`&str\` instead of an owned \`String\` to borrow instead of move, or use \`Rc\` or \`Arc\` for shared ownership if multiple owners are needed.
Journey Context:
A developer writes a simple CLI tool: \`let name = String::from\("Alice"\); process\(name\); println\!\("Hello, \{\}\!", name\);\`. The compiler errors on the \`println\!\` with E0382, stating \`name\` was moved into \`process\`. The developer is confused, thinking "I just passed it, why is it gone?" They check the \`process\` signature: \`fn process\(n: String\)\`. They realize Rust moves ownership by default. They consider making \`process\` return the \`String\` back, but that's awkward. Searching "rust use of moved value", they find the Rust Book chapter on Ownership. They understand that \`String\` does not implement the \`Copy\` trait \(unlike \`i32\`\), so assignment or passing moves the heap data, invalidating the original variable. The solutions become clear: pass a reference \`&name\` \(changing signature to \`&String\` or \`&str\`\) to borrow, or clone the data with \`name.clone\(\)\` if the copy is cheap enough. They apply the reference fix, and the code compiles, understanding that borrowing allows use after the call without transferring ownership.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:32:30.531842+00:00— report_created — created