]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/ufcs-explicit-self-bad.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / ufcs-explicit-self-bad.rs
CommitLineData
1a4d82fc
JJ
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
13struct Foo {
14 f: isize,
15}
16
17impl Foo {
9cc50fc6 18 fn foo(self: isize, x: isize) -> isize { //~ ERROR mismatched method receiver
1a4d82fc
JJ
19 self.f + x
20 }
21}
22
23struct Bar<T> {
24 f: T,
25}
26
27impl<T> Bar<T> {
9cc50fc6 28 fn foo(self: Bar<isize>, x: isize) -> isize { //~ ERROR mismatched method receiver
1a4d82fc
JJ
29 x
30 }
9cc50fc6 31 fn bar(self: &Bar<usize>, x: isize) -> isize { //~ ERROR mismatched method receiver
1a4d82fc
JJ
32 x
33 }
34}
35
36trait SomeTrait {
37 fn dummy1(&self);
38 fn dummy2(&self);
39 fn dummy3(&self);
40}
41
42impl<'a, T> SomeTrait for &'a Bar<T> {
43 fn dummy1(self: &&'a Bar<T>) { }
5bcae85e
SL
44 fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched method receiver
45 //~^ ERROR mismatched method receiver
85aaf69f 46 fn dummy3(self: &&Bar<T>) {}
5bcae85e 47 //~^ ERROR mismatched method receiver
a7813a04
XL
48 //~| expected type `&&'a Bar<T>`
49 //~| found type `&&Bar<T>`
85aaf69f 50 //~| lifetime mismatch
5bcae85e 51 //~| ERROR mismatched method receiver
a7813a04
XL
52 //~| expected type `&&'a Bar<T>`
53 //~| found type `&&Bar<T>`
85aaf69f 54 //~| lifetime mismatch
1a4d82fc
JJ
55}
56
57fn 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}