Uh oh!
There was an error while loading. Please reload this page.
Make pointer field of Pin private - #119615
Conversation
As the fix-me comment suggested, use the macro hygiene of macros 2.0 to access the field in the `pin` macro. Therefore, the field can be made private.
rustbot
commented
Jan 5, 2024
(rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Noratrieb
commented
Jan 5, 2024
Back when this macro was added, @danielhenrymantilla did originally want to use a macro 2.0, but if I remember it correctly, it was decided that relying on such a macro was not good and that it should use a macro_rules with a hack instead. |
mohe2015
commented
Jan 5, 2024
What does |
Uh oh!
There was an error while loading. Please reload this page.
| // See https://doc.rust-lang.org/1.58.1/reference/destructors.html#temporary-lifetime-extension | ||
| // for more info. | ||
| $crate::pin::Pin::<&mut _> { pointer: &mut { $value } } | ||
| Pin { pointer: &mut { $value } } |
There was a problem hiding this comment.
Removal of turbofish type is orthogonal to field privacy / hygiene, and technically allows for code such as let p: Pin<*mut _> = pin!(...); (letting a coërcion happen on the pointer: ... assignment).
Since this whole thing is already quite tricky/subtle, let's not risk unnecessary flexibility (which appears to be unsound
| Pin{pointer:&mut{ $value }} | |
| Pin::<&mut_>{pointer:&mut{ $value }} |
There was a problem hiding this comment.
I've readded this and added a comment explaining why it should not be removed.
There was a problem hiding this comment.
I wonder if I should also add a test for this case in this PR, so that others cannot stumble over the same thing.
fmease
commented
Jan 5, 2024
fmease
commented
Jan 5, 2024
Well, it's going to show |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
mohe2015
commented
Jan 5, 2024
I sometimes compile the expanded code to get better source line information etc. and to my understanding I can't easily make it compile anymore then by adding the internal feature flag? Not a too big issue but just came to my mind. |
Mark-Simulacrum
commented
Jan 6, 2024
r? @Nilstrieb Perhaps you remember which team / group made the decision referenced here:
|
I went through the discussion and it looks like this was a libs-api team decision in a meeting: #93176 (comment) |
bors
commented
Jan 8, 2024
☔ The latest upstream changes (presumably #119722) made this pull request unmergeable. Please resolve the merge conflicts. |
I noticed today that there's also a comment in // Skip suggestions for unstable public fields (for example `Pin::pointer`)The example should probably be omitted. Apart from |
m-ou-se
commented
Jan 10, 2024
I don't think we're supposed to use full macro 2.0 hygiene in a public macro yet. cc @petrochenkov |
m-ou-se
commented
Feb 15, 2024
Considering #119562 is merged, macros 2.0 hygiene isn't ready yet, and the temporary lifetime rfc work progressing towards a solution for the |
This PR is an alternative to #119562.
By using the macro hygiene of macros 2.0 inside the
pinmacro, thepointerfield ofPindoes no longer need to be public. Hiding it avoids the issue outlined in #119562, against which a regression test is added.