]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/issues/issue-13204.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / run-pass / issues / issue-13204.rs
1 // Copyright 2012-2014 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 // run-pass
12 #![allow(unused_mut)]
13 // Test that when instantiating trait default methods, typeck handles
14 // lifetime parameters defined on the method bound correctly.
15
16
17 pub trait Foo {
18 fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> usize {
19 let mut xs = it.filter(|_| true);
20 xs.count()
21 }
22 }
23
24 pub struct Baz;
25
26 impl Foo for Baz {
27 // When instantiating `Foo::bar` for `Baz` here, typeck used to
28 // ICE due to the lifetime parameter of `bar`.
29 }
30
31 fn main() {
32 let x = Baz;
33 let y = vec![(), (), ()];
34 assert_eq!(x.bar(y.iter()), 3);
35 }