]> git.lizzy.rs Git - rust.git/blob - src/test/ui/methods/method-recursive-blanket-impl.rs
Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup
[rust.git] / src / test / ui / methods / method-recursive-blanket-impl.rs
1 // run-pass
2 #![allow(unused_variables)]
3 #![allow(unused_imports)]
4 // Test that we don't trigger on the blanket impl for all `&'a T` but
5 // rather keep autoderefing and trigger on the underlying impl.  To
6 // know not to stop at the blanket, we have to recursively evaluate
7 // the `T:Foo` bound.
8
9 // pretty-expanded FIXME #23616
10
11 use std::marker::Sized;
12
13 // Note: this must be generic for the problem to show up
14 trait Foo<A> {
15     fn foo(&self, a: A);
16 }
17
18 impl Foo<u8> for [u8] {
19     fn foo(&self, a: u8) {}
20 }
21
22 impl<'a, A, T> Foo<A> for &'a T where T: Foo<A> {
23     fn foo(&self, a: A) {
24         Foo::foo(*self, a)
25     }
26 }
27
28 trait Bar {
29     fn foo(&self);
30 }
31
32 struct MyType;
33
34 impl Bar for MyType {
35     fn foo(&self) {}
36 }
37
38 fn main() {
39     let mut m = MyType;
40     (&mut m).foo()
41 }