-
Notifications
You must be signed in to change notification settings - Fork 273
Use raw borrows instead of normal borrows #1355
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
base: master
Are you sure you want to change the base?
Conversation
Hmm, the CI failed on |
5055982
to
1343170
Compare
I asked around on The #dark-arts channel of the Rust Discord, and they assured me that |
ba9d215
to
fd5ac23
Compare
c2rust-transpile still use old nightly ( i think |
In that nightly version, the |
Sadly I am not able to make this work right now. I'm running into niche cases where a temporary is borrowed and its lifetime is extended. Rust does not extend the lifetime when using the raw borrow operator, only the normal borrow operator. This is making a few of the tests still fail. If there is a way to know exactly in which cases the borrow operator references a temporary, then that could potentially solve the issue. |
I think I found a way to deal with the issue, at least in the case of compound literals. That makes this pretty much ready I think, all the tests run successfully. Two questions still remain:
|
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.
Thanks for tackling this!
Does this fix #301, too?
Also, could you add the test cases from all of the issues? Preferably as snapshot tests.
61ea8d7
to
5d2398a
Compare
Sorry for all the code churn. The commits kinda got messed up by rebasing and I decided to just redo everything from the start. Currently, the CI is failing because it's trying to raw-borrow what is being translated to a Is there a way to test whether an array-to-pointer decay expression is a macro expansion that was translated into a Rust |
|
(void*)array
Cast Still Emits Invalid*mut _
Despite Fix for Scalar-to-void* Casts (Related to #1077) #1238.static mut
Function Pointer Translation in C2Rust for Safe Rust Semantics #1224.I was able to simplify the affected code as well.
&mut
is not allowed in static initialisers, but&raw mut
is, so no special casing was needed for that anymore.I noticed that there was some logic to determine whether reference-to-pointer decay happens automatically, or needs a cast. I don't know if that's still needed at all, I can strip it out if not. I never dealt with inline assembly before, so I wasn't sure how to handle references vs pointers in that context. I left it as it is for now.