transpile: Use raw borrows instead of normal borrows#1355
transpile: Use raw borrows instead of normal borrows#1355kkysen merged 3 commits intoimmunant:masterfrom
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:
|
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 |
decb06f to
d6de3dd
Compare
|
I added a check for EDIT: I figured out I needed |
c8cd778 to
40abc63
Compare
198e9d7 to
e6c639b
Compare
|
I haven't abandoned this PR, but as I worked on it I kept finding more things that needed fixing first before this can work:
|
kkysen
left a comment
There was a problem hiding this comment.
I haven't abandoned this PR, but as I worked on it I kept finding more things that needed fixing first before this can work:
Thanks for the continued work! This is definitely a big issue, and fixing it would make our output significantly more sound, so it's very much appreciated!
a932c34 to
44ff95b
Compare
1711ef3 to
7998e75
Compare
|
At long last this is finally passing all the tests! I think it's ready to be reviewed now. |
kkysen
left a comment
There was a problem hiding this comment.
Awesome! LGTM. There's just one little comment about the comment. I can fix that, though, and merge.
|
Oh, I also think this fixes #301. You or I should also add a test for that. |
|
I added the test from #301, but it still triggers UB in |
|
Per Ralf:
pointers have to be recreated after that field access. |
What about if it was |
static mutFunction Pointer Translation in C2Rust for Safe Rust Semantics #1224.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.