]> git.lizzy.rs Git - rust.git/blob - tests/ui/confuse-field-and-method/issue-33784.rs
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24
[rust.git] / tests / ui / confuse-field-and-method / issue-33784.rs
1 use std::ops::Deref;
2
3 struct Obj<F> where F: FnMut() -> u32 {
4     fn_ptr: fn() -> (),
5     closure: F,
6 }
7
8 struct C {
9     c_fn_ptr: fn() -> (),
10 }
11
12 struct D(C);
13
14 impl Deref for D {
15     type Target = C;
16     fn deref(&self) -> &C {
17         &self.0
18     }
19 }
20
21
22 fn empty() {}
23
24 fn main() {
25     let o = Obj { fn_ptr: empty, closure: || 42 };
26     let p = &o;
27     p.closure(); //~ ERROR no method named `closure` found
28     let q = &p;
29     q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
30     let r = D(C { c_fn_ptr: empty });
31     let s = &r;
32     s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
33 }