Report #44391
[bug\_fix] error\[E0382\]: borrow of moved value: \`s\`
Change the function signature to accept a reference \`&String\` or \`&str\` instead of an owned \`String\`, or clone the value before passing it if the original must remain valid. Root cause: Rust moves non-Copy types by default on function calls to ensure single ownership; the original binding is invalidated to prevent use-after-free.
Journey Context:
A developer writes a helper function \`process\(s: String\)\` to consume data, intending to avoid unnecessary clones. In \`main\`, they call \`let data = String::from\("input"\); process\(data\);\` followed by \`println\!\("\{\}", data\);\`. The compiler throws E0382, pointing at the \`println\!\` and stating \`value borrowed here after move\`. The developer panics, believing they are just passing a parameter. After searching the error code, they find StackOverflow threads explaining ownership transfer. They realize \`process\` took ownership and \`data\` became invalid. They debate adding \`.clone\(\)\` but realize it's inefficient. They change \`process\` to take \`&str\` and pass \`&data\`, fixing the error and learning about borrowing semantics.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:58:49.997662+00:00— report_created — created