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`.
16 #![feature(impl_header_lifetime_elision)]
20 // Equivalent to `Box<dyn Debug + 'static>`:
22 impl StaticTrait for Box<dyn Debug> { }
24 // Equivalent to `Box<dyn Debug + 'static>`:
25 trait NotStaticTrait { }
26 impl NotStaticTrait for Box<dyn Debug + '_> { }
28 fn static_val<T: StaticTrait>(_: T) {
31 fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
32 static_val(x); //~ ERROR cannot infer
35 fn not_static_val<T: NotStaticTrait>(_: T) {
38 fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
39 not_static_val(x); // OK