I was trying to develop a tool to analysis rust code. I tried to get mir code for external functions with optimized_mir. The compiler report that it can't found mir for my own external library and std, but crate core works well... I don't know why and how can I import external crate's metadata?
MIR is normally only encoded in the metadata for generic functions,
#[inline] functions and const functions. You can compile all crates with
-Zalways-encode-mir=yes to get the MIR for all functions.
Thanks for you reply! It's really helpful!
Now I rebuild my library and std with the flag. But some functions in std/core do not have mir. For example, intrinsics. Seems rustc didn't provide a interface like opt_optimized_mir that returns an option, for in case if there is no mir for the function, return None.
Will it be useful if there is an opt_optimized_mir? Or everyone should be carefully to know the function do have mir before they call optimized_mir?
You can use
tcx.is_mir_available I think.
Thanks! I'm so silly
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.