Skip to content

Commit 644a5a3

Browse files
committed
enable fuzzy_provenance_casts lint in liballoc
1 parent 7477c1f commit 644a5a3

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

library/alloc/benches/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#![feature(iter_next_chunk)]
66
#![feature(repr_simd)]
77
#![feature(slice_partition_dedup)]
8+
#![feature(strict_provenance)]
89
#![feature(test)]
10+
#![deny(fuzzy_provenance_casts)]
911

1012
extern crate test;
1113

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
//
8383
// Lints:
8484
#![deny(unsafe_op_in_unsafe_fn)]
85+
#![deny(fuzzy_provenance_casts)]
8586
#![warn(deprecated_in_future)]
8687
#![warn(missing_debug_implementations)]
8788
#![warn(missing_docs)]

library/alloc/tests/fmt.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use std::cell::RefCell;
44
use std::fmt::{self, Write};
5+
use std::ptr;
56

67
#[test]
78
fn test_format() {
@@ -76,14 +77,14 @@ fn test_format_macro_interface() {
7677
t!(format!("{}", "foo"), "foo");
7778
t!(format!("{}", "foo".to_string()), "foo");
7879
if cfg!(target_pointer_width = "32") {
79-
t!(format!("{:#p}", 0x1234 as *const isize), "0x00001234");
80-
t!(format!("{:#p}", 0x1234 as *mut isize), "0x00001234");
80+
t!(format!("{:#p}", ptr::invalid::<isize>(0x1234)), "0x00001234");
81+
t!(format!("{:#p}", ptr::invalid_mut::<isize>(0x1234)), "0x00001234");
8182
} else {
82-
t!(format!("{:#p}", 0x1234 as *const isize), "0x0000000000001234");
83-
t!(format!("{:#p}", 0x1234 as *mut isize), "0x0000000000001234");
83+
t!(format!("{:#p}", ptr::invalid::<isize>(0x1234)), "0x0000000000001234");
84+
t!(format!("{:#p}", ptr::invalid_mut::<isize>(0x1234)), "0x0000000000001234");
8485
}
85-
t!(format!("{:p}", 0x1234 as *const isize), "0x1234");
86-
t!(format!("{:p}", 0x1234 as *mut isize), "0x1234");
86+
t!(format!("{:p}", ptr::invalid::<isize>(0x1234)), "0x1234");
87+
t!(format!("{:p}", ptr::invalid_mut::<isize>(0x1234)), "0x1234");
8788
t!(format!("{A:x}"), "aloha");
8889
t!(format!("{B:X}"), "adios");
8990
t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃");

library/alloc/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#![feature(strict_provenance)]
4848
#![feature(once_cell)]
4949
#![feature(drain_keep_rest)]
50+
#![deny(fuzzy_provenance_casts)]
5051

5152
use std::collections::hash_map::DefaultHasher;
5253
use std::hash::{Hash, Hasher};

0 commit comments

Comments
 (0)