File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
crates/core_simd/src/elements Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -83,17 +83,21 @@ where
83
83
84
84
#[ inline]
85
85
fn addr ( self ) -> Self :: Usize {
86
- // Safety: Since `addr` discards provenance, this is safe.
86
+ // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
87
+ // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
88
+ // provenance).
87
89
unsafe { core:: mem:: transmute_copy ( & self ) }
88
-
89
- //TODO switch to casts when available
90
- //self.cast()
91
90
}
92
91
93
92
#[ inline]
94
- fn with_addr ( self , addr : Self :: Usize ) -> Self {
93
+ fn with_addr ( self , _addr : Self :: Usize ) -> Self {
95
94
unimplemented ! ( )
96
95
/*
96
+ // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
97
+ //
98
+ // In the mean-time, this operation is defined to be "as if" it was
99
+ // a wrapping_offset, so we can emulate it as such. This should properly
100
+ // restore pointer provenance even under today's compiler.
97
101
self.cast::<*const u8>()
98
102
.wrapping_offset(addr.cast::<isize>() - self.addr().cast::<isize>())
99
103
.cast()
Original file line number Diff line number Diff line change @@ -78,17 +78,21 @@ where
78
78
79
79
#[ inline]
80
80
fn addr ( self ) -> Self :: Usize {
81
- // Safety: Since `addr` discards provenance, this is safe.
81
+ // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
82
+ // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
83
+ // provenance).
82
84
unsafe { core:: mem:: transmute_copy ( & self ) }
83
-
84
- //TODO switch to casts when available
85
- //self.cast()
86
85
}
87
86
88
87
#[ inline]
89
- fn with_addr ( self , addr : Self :: Usize ) -> Self {
88
+ fn with_addr ( self , _addr : Self :: Usize ) -> Self {
90
89
unimplemented ! ( )
91
90
/*
91
+ // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
92
+ //
93
+ // In the mean-time, this operation is defined to be "as if" it was
94
+ // a wrapping_offset, so we can emulate it as such. This should properly
95
+ // restore pointer provenance even under today's compiler.
92
96
self.cast::<*mut u8>()
93
97
.wrapping_offset(addr.cast::<isize>() - self.addr().cast::<isize>())
94
98
.cast()
You can’t perform that action at this time.
0 commit comments