Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was originally reported by @danielhenrymantilla in https://discord.com/channels/273534239310479360/512792629516173323/870075511009857617.
Currently, you can break the soundness of the pin-project by overriding the private module as follows.
Considering that it uses a hidden private API that is not guaranteed to be stable, I don't think this will actually happen except in cases where users intentionally abuse it or use a malicious crate. Also, in such a case, fixing this would not help much because the attacker can do anything.
That said, it seems relatively easy to fix this, so I'm going to fix this.
playground
This patch forces the macro to refer to the
pin-project
crate by referring to the_pin_project
imported into theconst _
scope instead of::pin_project
.pin-project/tests/expand/pub/struct.expanded.rs
Lines 21 to 23 in 7444436
pin-project/tests/expand/pub/struct.expanded.rs
Line 49 in 7444436
In the above example, a user-implemented Drop is detected, resulting in an error.
pin-project/tests/ui/pin_project/override-priv-mod.stderr
Lines 1 to 10 in 7444436
If other items (e.g.,
PinnedDrop
) are replaced in the same way, either nothing happens (nothing is affected because macro doesn't use them), or#[pin_project]
and#[pinned_drop]
refer to different items, resulting in an error.