RPIT can't capture LUB of two lifetimes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I'm not sure if this is a bug or not.
fn weird(x: &i32, y: &i32) -> impl Sized {
[x, y]
}
This code doesn't compile, giving the following error.
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds
--> src/lib.rs:2:5
|
1 | fn weird(x: &i32, y: &i32) -> impl Sized {
| ---------- opaque type defined here
2 | [x, y]
| ^^^^^^
|
= note: hidden type `[&i32; 2]` captures lifetime `'_`
For more information about this error, try `rustc --explain E0700`.
The return type captures the lifetime that outlives both the input lifetimes. There is not an easy way to name this lifetime. At the very least, the error is rather confusing.
Seems related to https://github.com/rust-lang/rust/issues/128752
Meta
Reproducible on the playground in version 1.93.0-nightly (2025-11-01 bd3ac0330018c23b111b)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust Playground reproduction on nightly 1.93.0 and inspect the E0700 diagnostic for the weird function. Compare the behavior and proposed scope with issue 128752; the work is complete when the behavior is classified and, if appropriate, the lifetime-capture error is made less confusing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100