]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/ty-outlives/ty-param-fn-body.rs
Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
[rust.git] / tests / ui / nll / ty-outlives / ty-param-fn-body.rs
1 // Test that we assume that universal types like `T` outlive the
2 // function body.
3
4 #![allow(warnings)]
5
6 use std::cell::Cell;
7
8 // No errors here, because `'a` is local to the body.
9 fn region_within_body<T>(t: T) {
10     let some_int = 22;
11     let cell = Cell::new(&some_int);
12     outlives(cell, t)
13 }
14
15 // Error here, because T: 'a is not satisfied.
16 fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) {
17     outlives(cell, t)
18     //~^ ERROR the parameter type `T` may not live long enough
19 }
20
21 fn outlives<'a, T>(x: Cell<&'a usize>, y: T)
22 where
23     T: 'a,
24 {
25 }
26
27 fn main() {}