2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_mut)]
|
2014-04-13 19:33:04 -05:00
|
|
|
// Test that when instantiating trait default methods, typeck handles
|
|
|
|
// lifetime parameters defined on the method bound correctly.
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2014-04-13 19:33:04 -05:00
|
|
|
pub trait Foo {
|
2015-03-25 19:06:52 -05:00
|
|
|
fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> usize {
|
2014-04-13 19:33:04 -05:00
|
|
|
let mut xs = it.filter(|_| true);
|
2014-06-06 01:18:51 -05:00
|
|
|
xs.count()
|
2014-04-13 19:33:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Baz;
|
|
|
|
|
|
|
|
impl Foo for Baz {
|
|
|
|
// When instantiating `Foo::bar` for `Baz` here, typeck used to
|
|
|
|
// ICE due to the lifetime parameter of `bar`.
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Baz;
|
2016-10-29 16:54:04 -05:00
|
|
|
let y = vec![(), (), ()];
|
2014-04-13 19:33:04 -05:00
|
|
|
assert_eq!(x.bar(y.iter()), 3);
|
|
|
|
}
|