# \[Pre-RFC\] \`field\_projection\`

**URL:** <https://internals.rust-lang.org/t/pre-rfc-field-projection/17383>\
**Category:** language design\
**Created:** [September 13, 2022, 8:21pm UTC](https://internals.rust-lang.org/t/pre-rfc-field-projection/17383 "2022-09-13T20:21:00Z")\
**Posts on this page:** 1\
**Showing post:** 57

<div class="post-metadata">

**Author:** ![pitaj](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/pitaj/32/11262_2.png) [@pitaj](https://internals.rust-lang.org/u/pitaj)\
**Post date:** [September 21, 2022, 9:21pm UTC](https://internals.rust-lang.org/t/pre-rfc-field-projection/17383/57 "2022-09-21T21:21:18Z")

</div>

> [@y86-dev](#):
>
> You are not able to access fields that are not visible to the current module (I think I did not mention that yet in the RFC).

That was my understanding from the get go.

> [@y86-dev](#):
>
> `main` clearly accesses the field directly. I suggest moving the struct definition into its own module.

Unsoundness shouldn't be possible within the module, either. But if it helps, just imagine that `data` is a public field. The type is still sound in that case.

> [@y86-dev](#):
>
> [Here](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=07c84ef834c21e01bbfa475b666c849d) is your example implemented with `pin-project`

Yes, but `#[pin_project]` is an opt-in thing. They only guarantee it's safe in the absence of other unsafe code. When applying `#[pin_project]`, you must be sure that your type is still sound when projecting all fields (whether with or without Pin wrapping).

However, how you have it, this language feature applies by default, and can allow undefined behavior in safe code for a previously sound type. It doesn't matter whether it's within the same module or a publicly visible field. It allows unsound usage of existing sound types just by existing, because it projects all fields by default.

If instead, you had to opt-in by explicitly enumerating which fields are projectable (or if your type as a whole is projectable - though that is less flexible), it wouldn't be a problem.

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-field-projection/17383)._
