]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 | 2 | #![allow(unused_mut)] |
1a4d82fc JJ |
3 | // Test that when instantiating trait default methods, typeck handles |
4 | // lifetime parameters defined on the method bound correctly. | |
5 | ||
c34b1796 | 6 | |
1a4d82fc | 7 | pub trait Foo { |
c34b1796 | 8 | fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> usize { |
1a4d82fc JJ |
9 | let mut xs = it.filter(|_| true); |
10 | xs.count() | |
11 | } | |
12 | } | |
13 | ||
14 | pub struct Baz; | |
15 | ||
16 | impl Foo for Baz { | |
17 | // When instantiating `Foo::bar` for `Baz` here, typeck used to | |
18 | // ICE due to the lifetime parameter of `bar`. | |
19 | } | |
20 | ||
21 | fn main() { | |
22 | let x = Baz; | |
c30ab7b3 | 23 | let y = vec![(), (), ()]; |
1a4d82fc JJ |
24 | assert_eq!(x.bar(y.iter()), 3); |
25 | } |