-
Couldn't load subscription status.
- Fork 13.9k
Description
This is a tracking issue for the RFC "Infer T: 'x outlives requirements on structs " (rust-lang/rfcs#2093).
Current status:
Implemented and we have decided to stabilize. We still need someone to make the stabilization PR! Mentoring instructions here:
https://github.com/rust-lang/rust/issue_comments#issuecomment-411781121
Until then, you can use this by adding #![feature(infer_outlives_requirements)] to your crate.
Steps:
- Implement the RFC (mentoring instructions here)
- Adjust documentation (see instructions on forge)
- Stabilization PR (see instructions on forge)
Unresolved questions:
The interaction with 'static remains a bit unclear. For example, do we want to infer a T: 'static requirement on the type parameter T here? The code currently will do so, arguably leading to confusing errors.
#![feature(infer_outlives_requirements)]
struct Foo<T> { t: &'static T }
fn main() {
let x = 3;
let _ = Foo { t: &x };
}