]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/issue-13853.rs
86a6bdfd4dde4d5c1b1898a50272e22c43ed5a37
[rust.git] / src / test / compile-fail / issue-13853.rs
1 // Copyright 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 trait Node {
12     fn zomg();
13 }
14
15 trait Graph<N: Node> {
16     fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I
17         where N: 'a;
18 }
19
20 impl<N: Node> Graph<N> for Vec<N> {
21     fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
22         where N: 'a
23     {
24         self.iter() //~ ERROR mismatched types
25     }
26 }
27
28 struct Stuff;
29
30 impl Node for Stuff {
31     fn zomg() {
32         println!("zomg");
33     }
34 }
35
36 fn iterate<N: Node, G: Graph<N>>(graph: &G) {
37     for node in graph.iter() { //~ ERROR no method named `iter` found
38         node.zomg();
39     }
40 }
41
42 pub fn main() {
43     let graph = Vec::new();
44
45     graph.push(Stuff);
46
47     iterate(graph); //~ ERROR mismatched types
48 }