]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/ufcs-explicit-self-bad.rs
e997cf47c733373780c1d9de67ce9982526f7687
[rust.git] / src / test / compile-fail / ufcs-explicit-self-bad.rs
1 // Copyright 2012 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 #![feature(box_syntax)]
12
13 struct Foo {
14     f: isize,
15 }
16
17 impl Foo {
18     fn foo(self: isize, x: isize) -> isize {  //~ ERROR mismatched types
19         self.f + x
20     }
21 }
22
23 struct Bar<T> {
24     f: T,
25 }
26
27 impl<T> Bar<T> {
28     fn foo(self: Bar<isize>, x: isize) -> isize { //~ ERROR mismatched types
29         x
30     }
31     fn bar(self: &Bar<usize>, x: isize) -> isize {   //~ ERROR mismatched types
32         x
33     }
34 }
35
36 trait SomeTrait {
37     fn dummy1(&self);
38     fn dummy2(&self);
39     fn dummy3(&self);
40 }
41
42 impl<'a, T> SomeTrait for &'a Bar<T> {
43     fn dummy1(self: &&'a Bar<T>) { }
44     fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched types
45     //~^ ERROR mismatched types
46     fn dummy3(self: &&Bar<T>) {}
47     //~^ ERROR mismatched types
48     //~| expected type `&&'a Bar<T>`
49     //~| found type `&&Bar<T>`
50     //~| lifetime mismatch
51     //~| ERROR mismatched types
52     //~| expected type `&&'a Bar<T>`
53     //~| found type `&&Bar<T>`
54     //~| lifetime mismatch
55 }
56
57 fn main() {
58     let foo = box Foo {
59         f: 1,
60     };
61     println!("{}", foo.foo(2));
62     let bar = box Bar {
63         f: 1,
64     };
65     println!("{} {}", bar.foo(2), bar.bar(2));
66 }