]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs
Remove licenses
[rust.git] / src / test / ui / impl-trait / must_outlive_least_region_or_bound.rs
1 use std::fmt::Debug;
2
3 fn elided(x: &i32) -> impl Copy { x }
4 //~^ ERROR explicit lifetime required in the type of `x` [E0621]
5
6 fn explicit<'a>(x: &'a i32) -> impl Copy { x }
7 //~^ ERROR cannot infer an appropriate lifetime
8
9 trait LifetimeTrait<'a> {}
10 impl<'a> LifetimeTrait<'a> for &'a i32 {}
11
12 fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
13 //~^ ERROR cannot infer an appropriate lifetime
14
15 // Tests that a closure type contianing 'b cannot be returned from a type where
16 // only 'a was expected.
17 fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
18     //~^ ERROR lifetime mismatch
19     move |_| println!("{}", y)
20 }
21
22 fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
23     //~^ ERROR the parameter type `T` may not live long enough
24     x
25 }
26
27 fn main() {}