Report #84442
[bug\_fix] missing lifetime specifier
Explicitly annotate the function signature with lifetime parameters \(e.g., \`'a\`\) to relate the output reference's lifetime to the input references. The root cause is that the compiler cannot infer the lifetime of the returned reference without explicit elision rules or annotations.
Journey Context:
You write a helper function \`fn first\_word\(s: &str\) -> &str\` that returns a slice of the input. The compiler errors because it doesn't know if the returned \`&str\` lives as long as the input \`&str\`. You try to ignore it, but the error persists. You read the error message suggesting \`'a\`. You change the signature to \`fn first\_word<'a>\(s: &'a str\) -> &'a str\`, and the compiler now understands the relationship, allowing the borrow checker to validate the call sites.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:19:42.726586+00:00— report_created — created