Skip to content

Commit 11363c7

Browse files
committed
Fix failing UI test
1 parent f203e1e commit 11363c7

File tree

3 files changed

+9
-37
lines changed

3 files changed

+9
-37
lines changed

tests/ui/invalid_null_ptr_usage.fixed

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ fn main() {
2525

2626
let _a: A = std::ptr::replace(core::ptr::NonNull::dangling().as_ptr(), A);
2727

28-
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
29-
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
30-
31-
let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(core::ptr::NonNull::dangling().as_ptr(), 0);
32-
3328
std::ptr::swap::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A);
3429
std::ptr::swap::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr());
3530

tests/ui/invalid_null_ptr_usage.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ fn main() {
2525

2626
let _a: A = std::ptr::replace(std::ptr::null_mut(), A);
2727

28-
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null(), 0);
29-
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0);
30-
31-
let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0);
32-
3328
std::ptr::swap::<A>(std::ptr::null_mut(), &mut A);
3429
std::ptr::swap::<A>(&mut A, std::ptr::null_mut());
3530

tests/ui/invalid_null_ptr_usage.stderr

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,70 +85,52 @@ LL | let _a: A = std::ptr::replace(std::ptr::null_mut(), A);
8585
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
8686

8787
error: pointer must be non-null
88-
--> tests/ui/invalid_null_ptr_usage.rs:28:69
89-
|
90-
LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null(), 0);
91-
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
92-
93-
error: pointer must be non-null
94-
--> tests/ui/invalid_null_ptr_usage.rs:29:69
95-
|
96-
LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0);
97-
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
98-
99-
error: pointer must be non-null
100-
--> tests/ui/invalid_null_ptr_usage.rs:31:73
101-
|
102-
LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0);
103-
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
104-
105-
error: pointer must be non-null
106-
--> tests/ui/invalid_null_ptr_usage.rs:33:29
88+
--> tests/ui/invalid_null_ptr_usage.rs:28:29
10789
|
10890
LL | std::ptr::swap::<A>(std::ptr::null_mut(), &mut A);
10991
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
11092

11193
error: pointer must be non-null
112-
--> tests/ui/invalid_null_ptr_usage.rs:34:37
94+
--> tests/ui/invalid_null_ptr_usage.rs:29:37
11395
|
11496
LL | std::ptr::swap::<A>(&mut A, std::ptr::null_mut());
11597
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
11698

11799
error: pointer must be non-null
118-
--> tests/ui/invalid_null_ptr_usage.rs:36:44
100+
--> tests/ui/invalid_null_ptr_usage.rs:31:44
119101
|
120102
LL | std::ptr::swap_nonoverlapping::<A>(std::ptr::null_mut(), &mut A, 0);
121103
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
122104

123105
error: pointer must be non-null
124-
--> tests/ui/invalid_null_ptr_usage.rs:37:52
106+
--> tests/ui/invalid_null_ptr_usage.rs:32:52
125107
|
126108
LL | std::ptr::swap_nonoverlapping::<A>(&mut A, std::ptr::null_mut(), 0);
127109
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
128110

129111
error: pointer must be non-null
130-
--> tests/ui/invalid_null_ptr_usage.rs:39:25
112+
--> tests/ui/invalid_null_ptr_usage.rs:34:25
131113
|
132114
LL | std::ptr::write(std::ptr::null_mut(), A);
133115
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
134116

135117
error: pointer must be non-null
136-
--> tests/ui/invalid_null_ptr_usage.rs:41:35
118+
--> tests/ui/invalid_null_ptr_usage.rs:36:35
137119
|
138120
LL | std::ptr::write_unaligned(std::ptr::null_mut(), A);
139121
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
140122

141123
error: pointer must be non-null
142-
--> tests/ui/invalid_null_ptr_usage.rs:43:34
124+
--> tests/ui/invalid_null_ptr_usage.rs:38:34
143125
|
144126
LL | std::ptr::write_volatile(std::ptr::null_mut(), A);
145127
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
146128

147129
error: pointer must be non-null
148-
--> tests/ui/invalid_null_ptr_usage.rs:45:40
130+
--> tests/ui/invalid_null_ptr_usage.rs:40:40
149131
|
150132
LL | std::ptr::write_bytes::<usize>(std::ptr::null_mut(), 42, 0);
151133
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
152134

153-
error: aborting due to 25 previous errors
135+
error: aborting due to 22 previous errors
154136

0 commit comments

Comments
 (0)