rust - eh_personality 在哪里调用?

标签 rust

我正在尝试使用 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_personalitypanic!() 循环中在哪里被调用?

最佳答案

参见 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 is eh_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/

相关文章:

winapi - 将数据从 Windows Hook 传递到另一个进程的最佳方法是什么?

arrays - 创建一个具有枚举元素大小的数组

thread-safety - 克隆 () 的电Arc生命周期不够长

error-handling - 如何在 Rust 中将 glob::GlobError 转换为 io::Error?

rust - Path::join 没有做预期的事情

rust - 在 Rust 中确定 DynamicImage 的位深度

rust - 我怎样才能延长结构的生命周期,以便我可以用它调用 tokio::run?

rust - 在继承自另一个特征的特征中指定关联类型

rust - 难以理解 Rust 借用系统

rust - 文字整数值在 Rust 中是否具有特定类型?