a2298a6f19
Account for `for` lifetimes when constructing closure to see if dereferencing the return value would be valid. Fix #125634, fix #124563.
20 lines
391 B
Rust
20 lines
391 B
Rust
// #125634
|
|
struct Thing;
|
|
|
|
// Invariant in 'a, Covariant in 'b
|
|
struct TwoThings<'a, 'b>(*mut &'a (), &'b mut ());
|
|
|
|
impl Thing {
|
|
fn enter_scope<'a>(self, _scope: impl for<'b> FnOnce(TwoThings<'a, 'b>)) {}
|
|
}
|
|
|
|
fn foo() {
|
|
Thing.enter_scope(|ctx| {
|
|
SameLifetime(ctx); //~ ERROR lifetime may not live long enough
|
|
});
|
|
}
|
|
|
|
struct SameLifetime<'a>(TwoThings<'a, 'a>);
|
|
|
|
fn main() {}
|