]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/issue-7575.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / span / issue-7575.rs
1 // Test the mechanism for warning about possible missing `self` declarations.
2 trait CtxtFn {
3     fn f8(self, _: usize) -> usize;
4     fn f9(_: usize) -> usize;
5 }
6
7 trait OtherTrait {
8     fn f9(_: usize) -> usize;
9 }
10
11 // Note: this trait is not implemented, but we can't really tell
12 // whether or not an impl would match anyhow without a self
13 // declaration to match against, so we wind up prisizeing it as a
14 // candidate. This seems not unreasonable -- perhaps the user meant to
15 // implement it, after all.
16 trait UnusedTrait {
17     fn f9(_: usize) -> usize;
18 }
19
20 impl CtxtFn for usize {
21     fn f8(self, i: usize) -> usize {
22         i * 4
23     }
24
25     fn f9(i: usize) -> usize {
26         i * 4
27     }
28 }
29
30 impl OtherTrait for usize {
31     fn f9(i: usize) -> usize {
32         i * 8
33     }
34 }
35
36 struct Myisize(isize);
37
38 impl Myisize {
39     fn fff(i: isize) -> isize {
40         i
41     }
42 }
43
44 trait ManyImplTrait {
45     fn is_str() -> bool {
46         false
47     }
48 }
49
50 impl ManyImplTrait for String {
51     fn is_str() -> bool {
52         true
53     }
54 }
55
56 impl ManyImplTrait for usize {}
57 impl ManyImplTrait for isize {}
58 impl ManyImplTrait for char {}
59 impl ManyImplTrait for Myisize {}
60
61 fn no_param_bound(u: usize, m: Myisize) -> usize {
62     u.f8(42) + u.f9(342) + m.fff(42)
63             //~^ ERROR no method named `f9` found
64             //~| ERROR no method named `fff` found
65
66
67 }
68
69 fn param_bound<T: ManyImplTrait>(t: T) -> bool {
70     t.is_str()
71     //~^ ERROR no method named `is_str` found
72 }
73
74 fn main() {
75 }