]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/suggest-deferences/multiple-0.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / traits / suggest-deferences / multiple-0.rs
1 // run-rustfix
2 use std::ops::Deref;
3
4 trait Happy {}
5 struct LDM;
6 impl Happy for &LDM {}
7
8 struct Foo(LDM);
9 struct Bar(Foo);
10 struct Baz(Bar);
11 impl Deref for Foo {
12 type Target = LDM;
13 fn deref(&self) -> &Self::Target {
14 &self.0
15 }
16 }
17 impl Deref for Bar {
18 type Target = Foo;
19 fn deref(&self) -> &Self::Target {
20 &self.0
21 }
22 }
23 impl Deref for Baz {
24 type Target = Bar;
25 fn deref(&self) -> &Self::Target {
26 &self.0
27 }
28 }
29
30 fn foo<T>(_: T) where T: Happy {}
31
32 fn main() {
33 let baz = Baz(Bar(Foo(LDM)));
34 foo(&baz);
35 //~^ ERROR the trait bound `&Baz: Happy` is not satisfied
36 }