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(dyn_trait)]
17 #![feature(in_band_lifetimes)]
21 // Equivalent to `Box<dyn Debug + 'static>`:
23 impl StaticTrait for Box<dyn Debug> { }
25 // Equivalent to `Box<dyn Debug + 'static>`:
26 trait NotStaticTrait { }
27 impl NotStaticTrait for Box<dyn Debug + '_> { }
29 fn static_val<T: StaticTrait>(_: T) {
32 fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
33 static_val(x); //~ ERROR cannot infer
36 fn not_static_val<T: NotStaticTrait>(_: T) {
39 fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
40 not_static_val(x); // OK