]> git.lizzy.rs Git - rust.git/blob - src/test/ui/inherent-impls-overlap-check/overlap.rs
Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyup
[rust.git] / src / test / ui / inherent-impls-overlap-check / overlap.rs
1 // aux-build:repeat.rs
2
3 #![allow(unused)]
4
5 // This tests the allocating algo branch of the
6 // inherent impls overlap checker.
7 // This branch was added by PR:
8 // https://github.com/rust-lang/rust/pull/78317
9 // In this test, we repeat many impl blocks
10 // to trigger the allocating branch.
11
12 // Simple overlap
13
14 extern crate repeat;
15
16 struct Foo {}
17
18 repeat::repeat_with_idents!(impl Foo { fn IDENT() {} });
19
20 impl Foo { fn hello() {} } //~ERROR duplicate definitions with name `hello`
21 impl Foo { fn hello() {} }
22
23 // Transitive overlap
24
25 struct Foo2 {}
26
27 repeat::repeat_with_idents!(impl Foo2 { fn IDENT() {} });
28
29 impl Foo2 {
30     fn bar() {}
31     fn hello2() {} //~ERROR duplicate definitions with name `hello2`
32 }
33
34 impl Foo2 {
35     fn baz() {}
36     fn hello2() {}
37 }
38
39 // Slightly stronger transitive overlap
40
41 struct Foo3 {}
42
43 repeat::repeat_with_idents!(impl Foo3 { fn IDENT() {} });
44
45 impl Foo3 {
46     fn bar() {} //~ERROR duplicate definitions with name `bar`
47     fn hello3() {} //~ERROR duplicate definitions with name `hello3`
48 }
49
50 impl Foo3 {
51     fn bar() {}
52     fn hello3() {}
53 }
54
55 // Generic overlap
56
57 struct Bar<T>(T);
58
59 struct A;
60 struct B;
61
62 repeat::repeat_with_idents!(impl Bar<A> { fn IDENT() {} });
63
64 impl Bar<A> { fn foo() {} fn bar2() {} }
65 impl Bar<B> {
66     fn foo() {}
67     fn bar2() {} //~ERROR duplicate definitions with name `bar2`
68 }
69 impl Bar<B> { fn bar2() {} }
70
71 fn main() {}