summary refs log tree commit diff
path: root/src/test/compile-fail/issue-7575.rs
blob: 768177785cfbad32a10dc8bdbaf5f5e9d738df1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait CtxtFn {
    fn f8(self, uint) -> uint;
    fn f9(uint) -> uint; //~ NOTE candidate #
}

trait OtherTrait {
    fn f9(uint) -> uint; //~ NOTE candidate #
}

trait UnusedTrait { // This should never show up as a candidate
    fn f9(uint) -> uint;
}

impl CtxtFn for uint {
    fn f8(self, i: uint) -> uint {
        i * 4u
    }

    fn f9(i: uint) -> uint {
        i * 4u
    }
}

impl OtherTrait for uint {
    fn f9(i: uint) -> uint {
        i * 8u
    }
}

struct MyInt(int);

impl MyInt {
    fn fff(i: int) -> int { //~ NOTE candidate #1 is `MyInt::fff`
        i
    }
}

trait ManyImplTrait {
    fn is_str() -> bool { //~ NOTE candidate #1 is
        false
    }
}

impl ManyImplTrait for String {
    fn is_str() -> bool {
        true
    }
}

impl ManyImplTrait for uint {}
impl ManyImplTrait for int {}
impl ManyImplTrait for char {}
impl ManyImplTrait for MyInt {}

fn no_param_bound(u: uint, m: MyInt) -> uint {
    u.f8(42) + u.f9(342) + m.fff(42)
            //~^ ERROR type `uint` does not implement any method in scope named `f9`
            //~^^ NOTE found defined static methods, maybe a `self` is missing?
                        //~^^^ ERROR type `MyInt` does not implement any method in scope named `fff`
                        //~^^^^ NOTE found defined static methods, maybe a `self` is missing?
}

fn param_bound<T: ManyImplTrait>(t: T) -> bool {
    t.is_str()
    //~^ ERROR type `T` does not implement any method in scope named `is_str`
    //~^^ NOTE found defined static methods, maybe a `self` is missing?
}

fn main() {
}