1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
12 // 'b> MyTrait<'a> for &'b i32`.
18 #![feature(in_band_lifetimes)]
22 // This is equivalent to `MyTrait<'a> for &'b i32`, which is proven by
24 impl MyTrait<'_> for &i32 {
27 // When called, T will be `&'x i32` for some `'x`, so since we can
28 // prove that `&'x i32: for<'a> MyTrait<'a>, then we know that the
29 // lifetime parameter above is disconnected.
30 fn impls_my_trait<T: for<'a> MyTrait<'a>>() { }
32 fn impls_my_trait_val<T: for<'a> MyTrait<'a>>(_: T) {
33 impls_my_trait::<T>();
36 fn random_where_clause()
37 where for<'a, 'b> &'a i32: MyTrait<'b> { }
42 impls_my_trait_val(f);
44 impls_my_trait::<&'static i32>();
46 random_where_clause();