4 #![feature(in_band_lifetimes)]
6 fn foo(x
: &'x
u8) -> &'x
u8 { x }
7 fn foo2(x
: &'a
u8, y
: &u8) -> &'a
u8 { x }
9 fn check_in_band_can_be_late_bound() {
10 let _
: for<'x
> fn(&'x
u8, &u8) -> &'x
u8 = foo2
;
13 struct ForInherentNoParams
;
15 impl ForInherentNoParams
{
16 fn foo(x
: &'a
u32, y
: &u32) -> &'a
u32 { x }
22 fn inner(&self) -> &'a
u8 {
26 fn same_lifetime_as_parameter(&mut self, x
: &'a
u8) {
32 fn inner_2(&self) -> &'b
u8 {
36 fn reference_already_introduced_in_band_from_method_with_explicit_binders
<'a
>(
44 fn inner(&self) -> &'a
u8 {
50 fn my_lifetime(&self) -> &'a
u8;
51 fn any_lifetime() -> &'b
u8;
52 fn borrowed_lifetime(&'b
self) -> &'b
u8;
53 fn default_impl(&self, x
: &'b
u32, y
: &u32) -> &'b
u32 { x }
54 fn in_band_def_explicit_impl(&self, x
: &'b
u8);
57 impl MyTrait
<'a
> for Y
<&'a
u8> {
58 fn my_lifetime(&self) -> &'a
u8 { self.0 }
59 fn any_lifetime() -> &'b
u8 { &0 }
60 fn borrowed_lifetime(&'b
self) -> &'b
u8 { &*self.0 }
61 fn in_band_def_explicit_impl
<'b
>(&self, x
: &'b
u8) {}
64 fn test_hrtb_defined_lifetime_where
<F
>(_
: F
) where for<'a
> F
: Fn(&'a
u8) {}
65 fn test_hrtb_defined_lifetime_polytraitref
<F
>(_
: F
) where F
: for<'a
> Fn(&'a
u8) {}
67 fn reference_in_band_from_locals(x
: &'test
u32) -> &'test
u32 {
68 let y
: &'test
u32 = x
;
72 fn in_generics_in_band
<T
: MyTrait
<'a
>>(x
: &T
) {}
73 fn where_clause_in_band
<T
>(x
: &T
) where T
: MyTrait
<'a
> {}
74 fn impl_trait_in_band(x
: &impl MyTrait
<'a
>) {}
76 // Tests around using in-band lifetimes within existential traits.
78 trait FunkyTrait
<'a
> { }
79 impl<'a
, T
> FunkyTrait
<'a
> for T { }
80 fn ret_pos_impl_trait_in_band_outlives(x
: &'a
u32) -> impl ::std
::fmt
::Debug
+ 'a
{
83 fn ret_pos_impl_trait_in_band_param(x
: &'a
u32) -> impl FunkyTrait
<'a
> {
86 fn ret_pos_impl_trait_in_band_param_static(x
: &'a
u32) -> impl FunkyTrait
<'
static> + 'a
{
89 fn ret_pos_impl_trait_in_band_param_outlives(x
: &'a
u32) -> impl FunkyTrait
<'a
> + 'a
{
92 fn ret_pos_impl_trait_in_band_higher_ranked(x
: &'a
u32) -> impl for<'b
> FunkyTrait
<'b
> + 'a
{