Skip to content

Commit ff72187

Browse files
authored
Rollup merge of #104632 - RalfJung:core-test-strict-provenance, r=thomcc
avoid non-strict-provenance casts in libcore tests r? `@thomcc`
2 parents b2ee0df + 428ab59 commit ff72187

File tree

6 files changed

+8
-1
lines changed

6 files changed

+8
-1
lines changed

library/core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
// Lints:
9090
#![deny(rust_2021_incompatible_or_patterns)]
9191
#![deny(unsafe_op_in_unsafe_fn)]
92+
#![deny(fuzzy_provenance_casts)]
9293
#![warn(deprecated_in_future)]
9394
#![warn(missing_debug_implementations)]
9495
#![warn(missing_docs)]
@@ -162,6 +163,7 @@
162163
#![feature(slice_ptr_get)]
163164
#![feature(slice_split_at_unchecked)]
164165
#![feature(str_internals)]
166+
#![feature(strict_provenance)]
165167
#![feature(utf16_extra)]
166168
#![feature(utf16_extra_const)]
167169
#![feature(variant_count)]

library/core/src/ptr/const_ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ impl<T: ?Sized> *const T {
140140
/// assert_eq!(<*const u8>::from_bits(1), dangling);
141141
/// ```
142142
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
143+
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
143144
pub fn from_bits(bits: usize) -> Self
144145
where
145146
T: Sized,

library/core/src/ptr/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ pub const fn invalid_mut<T>(addr: usize) -> *mut T {
616616
#[inline]
617617
#[unstable(feature = "strict_provenance", issue = "95228")]
618618
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
619+
#[allow(fuzzy_provenance_casts)] // this *is* the strict provenance API one should use instead
619620
pub fn from_exposed_addr<T>(addr: usize) -> *const T
620621
where
621622
T: Sized,
@@ -653,6 +654,7 @@ where
653654
#[inline]
654655
#[unstable(feature = "strict_provenance", issue = "95228")]
655656
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
657+
#[allow(fuzzy_provenance_casts)] // this *is* the strict provenance API one should use instead
656658
pub fn from_exposed_addr_mut<T>(addr: usize) -> *mut T
657659
where
658660
T: Sized,

library/core/src/ptr/mut_ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ impl<T: ?Sized> *mut T {
146146
/// assert_eq!(<*mut u8>::from_bits(1), dangling);
147147
/// ```
148148
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
149+
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
149150
pub fn from_bits(bits: usize) -> Self
150151
where
151152
T: Sized,

library/core/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
#![feature(utf8_chunks)]
110110
#![feature(is_ascii_octdigit)]
111111
#![deny(unsafe_op_in_unsafe_fn)]
112+
#![deny(fuzzy_provenance_casts)]
112113

113114
extern crate test;
114115

library/core/tests/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ fn align_offset_issue_103361() {
677677
#[cfg(target_pointer_width = "16")]
678678
const SIZE: usize = 1 << 13;
679679
struct HugeSize([u8; SIZE - 1]);
680-
let _ = (SIZE as *const HugeSize).align_offset(SIZE);
680+
let _ = ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
681681
}
682682

683683
#[test]

0 commit comments

Comments
 (0)