I want to do some analysis in MIR. I want to know is there any command(-C or -Z) to generate MIR where Box occurs as a primitive type?
For example,
let mut boxn = Box::new(Node { x : 100}); // Node is a struct with only one filed.
boxn.x = 100;
Then, the generated MIR looks like below.
_3 = std::boxed::Box::<Node>::new(Node {{ x: 14_i32 }})
_24 = (((_3.0: std::ptr::Unique<Node>).0: std::ptr::NonNull<Node>).0: *const Node);
((*_24).0: i32) = 100_i32;
As we can see, boxn.x is unwind as a Place(_24) expression in MIR. I wonder is there any way to remove the first assignment. The generated MIR looks like
((*_3).0 : i32) = 100_i32
In addition, we can write
let mut boxn = Box::new(Node { x : 100}); // Node is a struct with only one filed.
boxn.deref_mut().x = 100;
Thus, we can get
_3 = std::boxed::Box::<Node>::new(Node {{ x: 14_i32 }})
_24 = <std::boxed::Box<Node> as std::ops::DerefMut>::deref_mut(move _25)
((*_24).0: i32) = 100_i32;
Whatever, can we keep Box as a primitive type in MIR?