-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Description
The following code yields a compilation error:
trait Foo<'a> {
fn foo(&'a mut self);
}
impl<'a, T: 'a> Foo<'a> for Vec<T> {
fn foo(&'a mut self) {}
}
fn bar<F>(x: &mut F) where F: for<'a> Foo<'a> {
x.foo();
}
fn main() {
let a = ();
let mut v = vec![&a]; //~ ERROR `a` does not live long enough
//~^ reference must be valid for the static lifetime
bar(&mut v);
}This is the correct behavior, as v clearly does not implement Foo<'a> for all 'a.
I would like to use something like the following instead, but there is no way to achieve it:
fn bar<'x, F>(x: &'x mut F) where F: for<'a outlived by 'x> Foo<'a> { ... }Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Type
Fields
Give feedbackNo fields configured for issues without a type.