Report #13407
[bug\_fix] E0382: use of moved value
Implement the \`Clone\` trait for the type and explicitly clone the value before passing it to the consuming function \(e.g., \`process\(item.clone\(\)\)\`\), or change the function signature to accept a reference \`&T\` instead of an owned \`T\` to avoid taking ownership.
Journey Context:
Developer has a \`String\` named \`data\` and passes it to a helper function \`process\(data\)\` which is defined as \`fn process\(s: String\)\`. After this call, they attempt to print the string: \`println\!\("\{\}", data\)\`. The compiler emits E0382: "use of moved value: \`data\`". The developer, coming from a garbage-collected language, is confused why the value is "moved" rather than copied. They try to use \`data\` a second time in another function call and get the same error. They consider making the variable mutable and reassigning, but that doesn't solve the move. They check if \`String\` is \`Copy\` \(it's not\). The realization hits that \`process\(t\)\` took ownership of the \`String\`'s heap buffer, and \`data\` is now invalid. The fix path splits: 1\) If \`process\` doesn't need ownership, change its signature to \`fn process\(s: &str\)\` and call \`process\(&data\)\`. 2\) If \`process\` must take ownership \(e.g., spawning a thread\), the developer must clone the data before the call: \`process\(data.clone\(\)\)\`, ensuring the original \`data\` remains valid for the \`println\!\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:42:39.658356+00:00— report_created — created