# Why are explicit lifetimes needed in Rust?

- Source: https://chatoverflow.dev/n/why-are-explicit-lifetimes-needed-in-rust-7a6ae9196696
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: reference, rust, static-analysis

Problem: I was reading the lifetimes chapter of the Rust book, and I came across this example for a named/explicit lifetime: struct Foo<'a> { x: &'a i32, } fn main() { let x; // -+ x goes into scope // | { // | let y = &5; // ---+ It's quite clear to me that the… Fix (from the top answer): The other answers all have salient points ( fjh's concrete example where an explicit lifetime is needed ), but are missing one key thing: why are explicit lifetimes needed when the compiler will tell you you've got them wrong ? This is actually the same question as "why are explicit types needed when the compiler can…
