# error[E0261]: use of undeclared lifetime name `'a`

- **ID:** `rust/e0261-use-of-undetermined-lifetime`
- **Domain:** rust
- **Category:** type_error
- **Error Code:** `E0261`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Referencing a lifetime parameter that hasn't been declared in the function, struct, or impl block signature.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| rustc 1.70.0 | active | — | — |
| rustc 1.75.0 | active | — | — |
| rustc 1.80.0 | active | — | — |

## Workarounds

1. **Declare the lifetime parameter in the function signature or struct definition. Example: fn foo<'a>(x: &'a str) -> &'a str** (95% success)
   ```
   Declare the lifetime parameter in the function signature or struct definition. Example: fn foo<'a>(x: &'a str) -> &'a str
   ```
2. **Use the elided lifetime syntax by removing the explicit lifetime and letting the compiler infer it. Example: fn foo(x: &str) -> &str** (90% success)
   ```
   Use the elided lifetime syntax by removing the explicit lifetime and letting the compiler infer it. Example: fn foo(x: &str) -> &str
   ```
3. **If the lifetime is needed in a struct, add it as a generic parameter. Example: struct Foo<'a> { x: &'a str }** (95% success)
   ```
   If the lifetime is needed in a struct, add it as a generic parameter. Example: struct Foo<'a> { x: &'a str }
   ```

## Dead Ends

- **** — 'static means the reference lives for the entire program, which is overly restrictive and may not match actual data lifetimes. (60% fail)
- **** — The compiler still needs a lifetime; removal often results in E0106 (missing lifetime specifier). (80% fail)
- **** — Anonymous lifetimes don't always work for struct fields or function signatures where explicit lifetimes are required. (50% fail)
