-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
disallows from_exposed_addr(ptr.addr()) if the code is under #![feature(strict_provenance)]. The argument of from_exposed_addr can be value of expose_addr while addr cannot.
Lint Name
create_ptr_from_unexposed_addr
Category
correctness
Advantage
- Prevents UB.
Drawbacks
None
Example
#![feature(strict_provenance)]
fn main() {
let elem = 0u64;
let x: *const u8 = std::ptr::from_exposed_addr((&elem as *const u64).addr())
}Could be written as:
let elem = 0u64;
let x: *const u8 = std::ptr::from_exposed_addr((&elem as *const u64).exposed_addr())Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints