]> git.proxmox.com Git - rustc.git/blame - src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / suggestions / lifetimes / trait-object-nested-in-impl-trait.rs
CommitLineData
f035d41b
XL
1trait Foo {}
2impl<'a, T: Foo> Foo for &'a T {}
3impl<T: Foo + ?Sized> Foo for Box<T> {}
4
5struct Iter<'a, T> {
6 current: Option<Box<dyn Foo + 'a>>,
7 remaining: T,
8}
9
10impl<'a, T> Iterator for Iter<'a, T>
11where
12 T: Iterator,
13 T::Item: Foo + 'a,
14{
15 type Item = Box<dyn Foo + 'a>;
16
17 fn next(&mut self) -> Option<Self::Item> {
18 let result = self.current.take();
19 self.current = Box::new(self.remaining.next()).map(|f| Box::new(f) as _);
20 result
21 }
22}
23
24struct Bar(Vec<Box<dyn Foo>>);
25
26impl Bar {
27 fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> {
28 Iter {
923072b8 29 //~^ ERROR lifetime may not live long enough
f035d41b 30 current: None,
923072b8 31 remaining: self.0.iter(),
f035d41b
XL
32 }
33 }
34}
35
36struct Baz(Vec<Box<dyn Foo>>);
37
38impl Baz {
39 fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
40 Iter {
923072b8 41 //~^ ERROR lifetime may not live long enough
f035d41b 42 current: None,
923072b8 43 remaining: self.0.iter(),
f035d41b
XL
44 }
45 }
46}
47
48struct Bat(Vec<Box<dyn Foo>>);
49
50impl Bat {
51 fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
52 Iter {
923072b8 53 //~^ ERROR lifetime may not live long enough
f035d41b 54 current: None,
923072b8 55 remaining: self.0.iter(),
f035d41b
XL
56 }
57 }
58}
59
60struct Ban(Vec<Box<dyn Foo>>);
61
62impl Ban {
63 fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> {
64 Iter {
923072b8 65 //~^ ERROR lifetime may not live long enough
f035d41b 66 current: None,
923072b8 67 remaining: self.0.iter(),
f035d41b
XL
68 }
69 }
70}
71
72fn main() {}