]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsafe/unsafe-fn-autoderef.rs
Rollup merge of #103033 - alyssais:pkg-config, r=joshtriplett
[rust.git] / src / test / ui / unsafe / unsafe-fn-autoderef.rs
1 struct Rec {
2     f: isize
3 }
4
5 fn f(p: *const Rec) -> isize {
6
7     // Test that * ptrs do not autoderef.  There is a deeper reason for
8     // prohibiting this, beyond making unsafe things annoying (which doesn't
9     // actually seem desirable to me).  The deeper reason is that if you
10     // have a type like:
11     //
12     //    enum foo = *foo;
13     //
14     // you end up with an infinite auto-deref chain, which is
15     // currently impossible (in all other cases, infinite auto-derefs
16     // are prohibited by various checks, such as that the enum is
17     // instantiable and so forth).
18
19     return p.f; //~ ERROR no field `f` on type `*const Rec`
20 }
21
22 fn main() {
23 }