1 // compile-flags:-Zborrowck=mir
2 
3 // Test that we assume that universal types like `T` outlive the
4 // function body.
5 
6 #![allow(warnings)]
7 
8 use std::cell::Cell;
9 
10 // No errors here, because `'a` is local to the body.
region_within_body<T>(t: T)11 fn region_within_body<T>(t: T) {
12     let some_int = 22;
13     let cell = Cell::new(&some_int);
14     outlives(cell, t)
15 }
16 
17 // Error here, because T: 'a is not satisfied.
region_static<'a, T>(cell: Cell<&'a usize>, t: T)18 fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) {
19     outlives(cell, t)
20     //~^ ERROR the parameter type `T` may not live long enough
21 }
22 
outlives<'a, T>(x: Cell<&'a usize>, y: T) where T: 'a,23 fn outlives<'a, T>(x: Cell<&'a usize>, y: T)
24 where
25     T: 'a,
26 {
27 }
28 
main()29 fn main() {}
30