2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(unused_mut)]
|
2014-04-14 00:33:04 +00:00
|
|
|
// Test that when instantiating trait default methods, typeck handles
|
|
|
|
// lifetime parameters defined on the method bound correctly.
|
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2014-04-14 00:33:04 +00:00
|
|
|
pub trait Foo {
|
2015-03-26 00:06:52 +00:00
|
|
|
fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> usize {
|
2014-04-14 00:33:04 +00:00
|
|
|
let mut xs = it.filter(|_| true);
|
2014-06-06 06:18:51 +00:00
|
|
|
xs.count()
|
2014-04-14 00:33:04 +00: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 21:54:04 +00:00
|
|
|
let y = vec![(), (), ()];
|
2014-04-14 00:33:04 +00:00
|
|
|
assert_eq!(x.bar(y.iter()), 3);
|
|
|
|
}
|