Report #5616
[bug\_fix] borrow of moved value: \`x\`
Clone the value before passing \(\`s.clone\(\)\`\), pass by reference \(\`&s\`\), or restructure to return ownership back. Root cause: Rust has move semantics by default for non-Copy types; when \`s\` is passed to a function, ownership moves to the callee, invalidating the original binding to prevent use-after-free.
Journey Context:
You create a \`String\`, pass it to a function \`process\(s\)\`, then try to print \`s\`. The compiler errors with \`borrow of moved value\`. You think about copying but aren't sure of the syntax. You try \`&s\` in the function call and change the parameter to \`&String\`. It works. You realize that without the \`&\`, the String's heap memory was transferred into the function, and the original \`s\` became a dangling pointer \(logically\). The borrow checker prevented a use-after-free. The fix works because cloning duplicates the heap data, or borrowing lets the callee temporarily view the data without taking ownership.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:45:02.810929+00:00— report_created — created