]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-escape-method.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-escape-method.rs
1 // Test a method call where the parameter `B` would (illegally) be
2 // inferred to a region bound in the method argument. If this program
3 // were accepted, then the closure passed to `s.f` could escape its
4 // argument.
5
6 struct S;
7
8 impl S {
9     fn f<B, F>(&self, _: F) where F: FnOnce(&i32) -> B {
10     }
11 }
12
13 fn main() {
14     let s = S;
15     s.f(|p| p) //~ ERROR lifetime may not live long enough
16 }