-
Notifications
You must be signed in to change notification settings - Fork 254
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
analyze: implement Box<T> rewrites #1106
Conversation
8a8bc96
to
b3aecb0
Compare
e1af765
to
6a091e1
Compare
) | ||
} | ||
mir_op::RewriteKind::DynOwnedWrap => { | ||
Rewrite::Call("std::result::Result::<_, ()>::Ok".to_string(), vec![hir_rw]) |
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.
Couldn't this just be an Option
?
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.
It could, but DynOwned
can be composed with Option<T>
if we encounter a nullable owned pointer, and Option<DynOwned<T>>
is clearer than Option<Option<T>>
. But c2rust-analyze doesn't yet have a run-time support library where we could define DynOwned<T>
, so for now we use the somewhat ugly Result<T, ()>
in place of DynOwned<T>
.
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.
Might be useful to add a comment.
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.
Added a comment on the translation of DynOwned
types: 95d4038
6a091e1
to
3cd8c2d
Compare
Looks like the Darwin CI error here is the same issue that's being fixed in #1146. Once that's merged, I'll rebase this and try the CI again. |
3cd8c2d
to
82e989c
Compare
This avoids the need for an `extern crate alloc` when testing rewritten code.
82e989c
to
95d4038
Compare
This branch adds rewrites to convert pointers with the
FREE
permission intoBox<T>
. This follows the dynamic ownership tracking proposal in #1097.Specific changes:
dyn_owned: bool
field toTypeDesc
, which indicates that the pointer type should be wrapped in a dynamic ownership wrapper.ZeroizeType
handling to support zero-initializing some pointer types (necessary to allowmalloc
/calloc
of structs that contain pointers).Box
anddyn_owned
related casts inmir_op
andrewrite::expr::convert
.malloc
,calloc
,free
, andrealloc
.