Closed
Description
It turns out that rustc generates mir that tries to cast unit reference to a trait object reference.
In our regression test rust-tests/cbmc-reg/Closure/main.rs
, the test closure_with_empty_args()
causes rustc to generate the following
In the context of
handling Result::<&i32, ()>::unwrap, std::result::Result::<T, E>::unwrap
we find rustc trying to cast &() to &dyn std::fmt::Debug with the following mir
let _1: std::result::Result<&i32, ()>
let _3: ()
let _6: &dyn std::fmt::Debug
let _7: &()
let _8: &()
_3 = move ((_1 as Err).0: E)
_8 = &_3
_7 = _8
_6 = move _7 as &dyn std::fmt::Debug (Pointer(Unsize))
This regression test passed with the old implementation of unsized pointer casts but fails with the new implementation that assumes only pointers are adts containing nested pointers can be cast to unsized objects. I'm not sure how the old code ever worked, and I'm not sure what the new code should be doing.