Skip to content

Commit

Permalink
add some tests for the interaction with existential impl trait
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Nov 22, 2017
1 parent d3e0c33 commit 79bf7db
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/test/run-pass/in-band-lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

#![allow(warnings)]
#![feature(in_band_lifetimes, universal_impl_trait)]
#![feature(in_band_lifetimes, universal_impl_trait, conservative_impl_trait)]

fn foo(x: &'x u8) -> &'x u8 { x }
fn foo2(x: &'a u8, y: &u8) -> &'a u8 { x }
Expand Down Expand Up @@ -81,4 +81,24 @@ fn in_generics_in_band<T: MyTrait<'a>>(x: &T) {}
fn where_clause_in_band<T>(x: &T) where T: MyTrait<'a> {}
fn impl_trait_in_band(x: &impl MyTrait<'a>) {}

// Tests around using in-band lifetimes within existential traits.

trait FunkyTrait<'a> { }
impl<'a, T> FunkyTrait<'a> for T { }
fn existential_impl_trait_in_band_outlives(x: &'a u32) -> impl ::std::fmt::Debug + 'a {
x
}
fn existential_impl_trait_in_band_param(x: &'a u32) -> impl FunkyTrait<'a> {
x
}
fn existential_impl_trait_in_band_param_static(x: &'a u32) -> impl FunkyTrait<'static> + 'a {
x
}
fn existential_impl_trait_in_band_param_outlives(x: &'a u32) -> impl FunkyTrait<'a> + 'a {
x
}
fn existential_impl_trait_in_band_higher_ranked(x: &'a u32) -> impl for<'b> FunkyTrait<'b> + 'a {
x
}

fn main() {}

0 comments on commit 79bf7db

Please sign in to comment.