我正在尝试使用 libcore 在 Rust 中实现操作系统。在文档中,it says that the eh_personality
function needs to be implemented .
然而,I see no usage of this function in libcore itself没有它我也能够编译、运行和执行 panics。
我在这里缺少什么吗? eh_personality
在 panic!()
循环中在哪里被调用?
最佳答案
参见 unstable-book: lang_items :
The first of these functions,
rust_eh_personality
, is used by the failure mechanisms of the compiler. This is often mapped to GCC's personality function (see the libstd implementation for more information), but crates which do not trigger a panic can be assured that this function is never called. The language item's name iseh_personality
.
据我所知,它是创建展开信息所必需的;如果您在 panic_fmt
语言项(函数 rust_begin_unwind
)中中止或循环,它可能不会被调用。
另请参阅 libpanic_abort/lib.rs 中的内部评论.
如果您搜索 rust_eh_personality
您会在 librustc_trans/context.rs: CodegenCx::eh_personality
中找到用法.搜索 eh_personality
应该揭示这个函数被调用的地方。 (用于代码生成,不是直接调用。)
搜索#[lang = "eh_personality"]
只显示定义个性的地方,而不是用法。
关于rust - eh_personality 在哪里调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48982154/