]>
Commit | Line | Data |
---|---|---|
0531ce1d XL |
1 | // Copyright 2015 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. | |
4 | // | |
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. | |
10 | ||
11 | // Check that the `'_` in `dyn Trait + '_` acts like ordinary elision, | |
12 | // and not like an object lifetime default. | |
13 | // | |
14 | // cc #48468 | |
15 | ||
0531ce1d XL |
16 | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { |
17 | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` | |
18 | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime | |
19 | } | |
20 | ||
21 | fn b<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> { | |
22 | Box::new(items.iter()) // OK, equivalent to c | |
23 | } | |
24 | ||
25 | fn c<'a, T>(items: &'a [T]) -> Box<dyn Iterator<Item=&'a T> + 'a> { | |
26 | Box::new(items.iter()) // OK, equivalent to b | |
27 | } | |
28 | ||
29 | fn main() { } |