immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.91k stars 229 forks source link

(`c2rust-analyze`) Support all ways of writing `addr_of!` during rewriting #912

Closed kkysen closed 1 year ago

kkysen commented 1 year ago

During rewriting, std::ptr::addr_of! seems to be special cased to an extent, as some other equivalent forms do not work. Specifically, these work:

See also https://github.com/immunant/c2rust/blob/11bf3514929133cd5ee44fe4eb5956bb0e4c07e8/c2rust-analyze/tests/analyze/string_casts.rs#L18-L21

There doesn't appear to be a specific error. Instead, this is printed:

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Error: ErrorGuaranteed(())
aneksteind commented 1 year ago

Can you be more specific about what "doesn't work" means? Error messages would be helpful

kkysen commented 1 year ago

Yeah, I'll add them.

kkysen commented 1 year ago

Hmm, it seems that now use std::ptr::addr_of; addr_of!(x); works? In a new, separate test from master, but I don't think I touched anything related.