]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-header-lifetime-elision/dyn-trait.rs
Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree
[rust.git] / src / test / ui / impl-header-lifetime-elision / dyn-trait.rs
1 // Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
2 // 'b> MyTrait<'a> for &'b i32`.
3
4 #![allow(warnings)]
5
6 use std::fmt::Debug;
7
8 // Equivalent to `Box<dyn Debug + 'static>`:
9 trait StaticTrait { }
10 impl StaticTrait for Box<dyn Debug> { }
11
12 // Equivalent to `Box<dyn Debug + 'static>`:
13 trait NotStaticTrait { }
14 impl NotStaticTrait for Box<dyn Debug + '_> { }
15
16 fn static_val<T: StaticTrait>(_: T) {
17 }
18
19 fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
20     static_val(x); //~ ERROR E0759
21 }
22
23 fn not_static_val<T: NotStaticTrait>(_: T) {
24 }
25
26 fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
27     not_static_val(x); // OK
28 }
29
30 fn main() {
31 }