Pre-RFC: unsafe attributes

RalfJ 提出一个 Pre-RFC ,提议为一些可能导致未定义行为的属性加上 unsafe,比如

rust
// SAFETY: there is no other global function of this name
#[unsafe(no_mangle)]
pub fn my_own_write(...) { ... }


之前有个issue 提出 #[no_mangle] 也是 Unsafe 的,在某些平台上(至少是 GNU/Linux,但也听说过 Windows 和其他几个平台),将两个静态库链接在一起,而这两个库都导出了一个同名的符号,那么哪个符号实际上被链接了,这是无法定义的。 相关issue https://github.com/rust-lang/rust/issues/28179

https://internals.rust-lang.org/t/pre-rfc-unsafe-attributes/17462
 
 
Back to Top