Skip to content

Commit 7f5addd

Browse files
committed
enable fuzzy_provenance_casts lint in libstd
1 parent 644a5a3 commit 7f5addd

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

library/std/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
#![allow(explicit_outlives_requirements)]
221221
#![allow(unused_lifetimes)]
222222
#![deny(rustc::existing_doc_keyword)]
223+
#![deny(fuzzy_provenance_casts)]
223224
// Ensure that std can be linked against panic_abort despite compiled with `-C panic=unwind`
224225
#![deny(ffi_unwind_calls)]
225226
// std may use features in a platform-specific way
@@ -597,7 +598,7 @@ mod panicking;
597598
mod personality;
598599

599600
#[path = "../../backtrace/src/lib.rs"]
600-
#[allow(dead_code, unused_attributes)]
601+
#[allow(dead_code, unused_attributes, fuzzy_provenance_casts)]
601602
mod backtrace_rs;
602603

603604
// Re-export macros defined in libcore.

library/std/src/os/windows/io/socket.rs

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl OwnedSocket {
9090
}
9191

9292
// FIXME(strict_provenance_magic): we defined RawSocket to be a u64 ;-;
93+
#[allow(fuzzy_provenance_casts)]
9394
#[cfg(not(target_vendor = "uwp"))]
9495
pub(crate) fn set_no_inherit(&self) -> io::Result<()> {
9596
cvt(unsafe {

library/std/src/personality/dwarf/eh.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use super::DwarfReader;
1515
use core::mem;
16+
use core::ptr;
1617

1718
pub const DW_EH_PE_omit: u8 = 0xFF;
1819
pub const DW_EH_PE_absptr: u8 = 0x00;
@@ -151,7 +152,7 @@ unsafe fn read_encoded_pointer(
151152

152153
// DW_EH_PE_aligned implies it's an absolute pointer value
153154
if encoding == DW_EH_PE_aligned {
154-
reader.ptr = round_up(reader.ptr as usize, mem::size_of::<usize>())? as *const u8;
155+
reader.ptr = reader.ptr.with_addr(round_up(reader.ptr.addr(), mem::size_of::<usize>())?);
155156
return Ok(reader.read::<usize>());
156157
}
157158

@@ -171,7 +172,7 @@ unsafe fn read_encoded_pointer(
171172
result += match encoding & 0x70 {
172173
DW_EH_PE_absptr => 0,
173174
// relative to address of the encoded value, despite the name
174-
DW_EH_PE_pcrel => reader.ptr as usize,
175+
DW_EH_PE_pcrel => reader.ptr.expose_addr(),
175176
DW_EH_PE_funcrel => {
176177
if context.func_start == 0 {
177178
return Err(());
@@ -184,7 +185,7 @@ unsafe fn read_encoded_pointer(
184185
};
185186

186187
if encoding & DW_EH_PE_indirect != 0 {
187-
result = *(result as *const usize);
188+
result = *ptr::from_exposed_addr::<usize>(result);
188189
}
189190

190191
Ok(result)

0 commit comments

Comments
 (0)