Report #11954
[bug\_fix] error\[E0106\]: missing lifetime specifier
Add an explicit lifetime parameter to the struct or function: change \`struct Foo \{ data: &str \}\` to \`struct Foo<'a> \{ data: &'a str \}\`. Root cause: When a struct holds a reference, the compiler cannot infer how long that reference must remain valid relative to the struct instance; you must explicitly annotate this relationship using lifetime parameters to ensure the reference doesn't dangle.
Journey Context:
Developer transitioning from garbage-collected languages attempts to create a struct that holds a string slice to avoid heap allocation: \`struct Config \{ host: &str \}\`. The compiler immediately stops with E0106. Developer first tries to add \`'static\` lifetime \(which works for string literals but fails at runtime when using parsed strings\), then learns about lifetime parameters. They add \`<'a>\` to the struct name and \`&'a str\` to the field. They then encounter secondary borrow checker errors when trying to use the struct, eventually understanding that the struct instance cannot outlive the data it references, leading to a refactor to use \`String\` \(owned\) instead of \`&str\` for long-lived config structs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:45:15.983306+00:00— report_created — created