Report #10281
[bug\_fix] E0726 implicit elided lifetime not allowed here
Explicitly write the elided lifetime using the reserved \`'\_\` syntax \(e.g., \`async fn get\(\) -> &'\_ str\`\) or explicitly name the lifetime \(e.g., \`async fn get<'a>\(\) -> &'a str\`\). This makes the lifetime contract explicit for the opaque Future return type. Root cause: \`async fn\` desugars to a return type of \`impl Future\`, and lifetime elision is not allowed inside opaque type implementations \(RPIT\) because the lifetime capture must be explicit.
Journey Context:
Developer writes \`async fn fetch\(&self\) -> &str\` expecting async/await to 'just work'. The compiler emits E0726: 'implicit elided lifetime not allowed here' pointing to the return type. The developer tries \`-> &'static str\` \(incorrect, forces static lifetime\), then tries \`-> &'\_ str\` \(works but they don't understand why\). They search the error code and find the Rust Reference on async functions. They learn that \`async fn\` is syntactic sugar for \`fn ... -> impl Future\`, and inside \`impl Trait\` \(opaque return types\), lifetime elision is forbidden to prevent accidental lifetime capture. The fix \`-> &'\_ str\` explicitly opts into the elided lifetime rules, while \`-> &'a str\` \(with \`async fn fetch<'a>\`\) makes it named. The developer learns that async fn lifetimes are subtle because the returned Future holds the reference across await points.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:15:23.851061+00:00— report_created — created