-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix compile failure for getter with return lifetime of self #3347
Conversation
526c73c
to
4a66263
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've pushed a commit which improves the implementation of impl_py_getter_def
a little bit.
I've identified a follow-up which will move code out of the macro-generated code and into the trampolines, so I'd like to ask to merge this as-is (even if the macro expression is still a bit verbose) because I'll simplify further in the follow up.
I also pushed a commit which moves all usage of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I welcome the reduction in Perl-style sigils by not quoting the GIL token, I somewhat fear regressions in macro hygiene due to this.
I am also not sure what the motivation for doing that change now is? Sure, this implies another reduction in sigil noise in the proc macro code, but to me, it appears small compared to possible regression in macro hygiene, especially which such a common identifier as py
(at least in PyO3 code bases).
I am pretty sure I am missing something, because this appears somewhat risky to me.
4a66263
to
686fe0a
Compare
That's a reasonable concern. The The To remove the hygiene concerns from this PR I've moved that commit to #3356 and replaced it here with a simpler commit which unifies all idents as |
While testing
main
downstream I noticed a compile failure caused by #3318, when the value returned from a#[getter]
has the same lifetime as the&self
receiver.This PR adds a corresponding test and fixes it. The solution is the usual trend for the macro function bodies towards expressions; there is a sequence of statements along the lines of
let item = ...; return convert(item)
, the PR changes this to just beconvert(...)
.This doesn't need a changelog entry as the compile failure never hit a released version.