]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-71676-1.rs
point at private fields in struct literal
[rust.git] / src / test / ui / issues / issue-71676-1.rs
1 // run-rustfix
2 use std::ops::Deref;
3 use std::ops::DerefMut;
4 struct Bar(u8);
5 struct Foo(Bar);
6 struct Emm(Foo);
7 impl Deref for Bar{
8     type Target = u8;
9     fn deref(&self) -> &Self::Target {
10         &self.0
11     }
12 }
13 impl Deref for Foo {
14     type Target = Bar;
15     fn deref(&self) -> &Self::Target {
16         &self.0
17     }
18 }
19 impl Deref for Emm {
20     type Target = Foo;
21     fn deref(&self) -> &Self::Target {
22         &self.0
23     }
24 }
25 impl DerefMut for Bar{
26     fn deref_mut(&mut self) -> &mut Self::Target {
27         &mut self.0
28     }
29 }
30 impl DerefMut for Foo {
31     fn deref_mut(&mut self) -> &mut Self::Target {
32         &mut self.0
33     }
34 }
35 impl DerefMut for Emm {
36     fn deref_mut(&mut self) -> &mut Self::Target {
37         &mut self.0
38     }
39 }
40 fn main() {
41     // Suggest dereference with arbitrary mutability
42     let a = Emm(Foo(Bar(0)));
43     let _: *const u8 = &a; //~ ERROR mismatched types
44
45     let mut a = Emm(Foo(Bar(0)));
46     let _: *mut u8 = &a; //~ ERROR mismatched types
47
48     let a = Emm(Foo(Bar(0)));
49     let _: *const u8 = &mut a; //~ ERROR mismatched types
50
51     let mut a = Emm(Foo(Bar(0)));
52     let _: *mut u8 = &mut a; //~ ERROR mismatched types
53 }