Closed kkysen closed 1 year ago
@spernsteiner, do you think #934 might fix this? I don't want to work on this too much if it's going to be overwritten by #934.
do you think https://github.com/immunant/c2rust/pull/934 might fix this?
I'm not sure. I tried merging together analyze-unlower
(#934) and kkysen/analyze-string-casts
(#839), but the tests failed, even without adding the example code above. I think the string cast branch is just out of date - merging it with master
produces the same error:
thread 'rustc' panicked at 'building TypeDesc for FIXED pointer requires a related pointee type', c2rust-analyze/src/type_desc.rs:75:5
stack backtrace:
0: rust_begin_unwind
at /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/library/core/src/panicking.rs:142:14
2: c2rust_analyze::type_desc::perms_to_desc
at ./src/type_desc.rs:75:5
3: c2rust_analyze::rewrite::expr::mir_op::ExprRewriteVisitor::visit_rvalue
at ./src/rewrite/expr/mir_op.rs:315:32
4: c2rust_analyze::rewrite::expr::mir_op::ExprRewriteVisitor::visit_statement::{{closure}}
at ./src/rewrite/expr/mir_op.rs:214:46
5: c2rust_analyze::rewrite::expr::mir_op::ExprRewriteVisitor::enter
at ./src/rewrite/expr/mir_op.rs:104:17
6: c2rust_analyze::rewrite::expr::mir_op::ExprRewriteVisitor::enter_assign_rvalue
at ./src/rewrite/expr/mir_op.rs:114:9
7: c2rust_analyze::rewrite::expr::mir_op::ExprRewriteVisitor::visit_statement
at ./src/rewrite/expr/mir_op.rs:214:17
8: c2rust_analyze::rewrite::expr::mir_op::gen_mir_rewrites
at ./src/rewrite/expr/mir_op.rs:583:13
Fixed by the refactor in #934.
Code with implicitly inserted
&raw
s, such ascrashes in the rewriter due to not handling the implicitly inserted
&raw
in the MIR:When the
&raw
is made explicit with anaddr_of!
, such asthings work again.
Note: These examples are taken from
string_casts.rs
from #839.