Closed
Description
After PR #6307, all functions coming from extern
blocks are considered safe if their name is found in this list. However, only functions defined in extern "rust-instrinsic"
blocks should get this treatment.
Expected outcome:
extern "rust-intrinsic" {
pub fn likely(b: bool) -> bool; // <- Safe to call since it comes from rust-intrinsic
}
extern "foo" {
pub fn bitreverse(x: u32) -> u32; // <- Unsafe to call as it doesn't come from rust-intrinsic
}
fn main() {
let _ = likely(true);
let _ = bitreverse(12);
//^^^^^^^^^^^^^^ This operation is unsafe and requires an unsafe function or block
}
As discussed in the comments to PR #6307, this should be simply a matter of checking the ABI
node of the extern block.
Possible solution strategy:
- Solve Design string tokens #6308
- Add a way to access the name of the
ABI
node
[email protected]
[email protected]
[email protected]
[email protected] "extern"
[email protected] " "
[email protected] "\"rust-intrinsic\""
- Modify this line so that functions are marked as safe if they come from an
extern "rust-intrinsic"
blocks AND their name matches the whitelist