Skip to content

Commit da9b138

Browse files
committed
Update test after const_ptr functions are must_use now
1 parent b8098fe commit da9b138

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

tests/ui/ptr_offset_with_cast.fixed

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ fn main() {
99
let offset_isize = 1_isize;
1010

1111
unsafe {
12-
ptr.add(offset_usize);
13-
ptr.offset(offset_isize as isize);
14-
ptr.offset(offset_u8 as isize);
12+
let _ = ptr.add(offset_usize);
13+
let _ = ptr.offset(offset_isize as isize);
14+
let _ = ptr.offset(offset_u8 as isize);
1515

16-
ptr.wrapping_add(offset_usize);
17-
ptr.wrapping_offset(offset_isize as isize);
18-
ptr.wrapping_offset(offset_u8 as isize);
16+
let _ = ptr.wrapping_add(offset_usize);
17+
let _ = ptr.wrapping_offset(offset_isize as isize);
18+
let _ = ptr.wrapping_offset(offset_u8 as isize);
1919
}
2020
}

tests/ui/ptr_offset_with_cast.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ fn main() {
99
let offset_isize = 1_isize;
1010

1111
unsafe {
12-
ptr.offset(offset_usize as isize);
13-
ptr.offset(offset_isize as isize);
14-
ptr.offset(offset_u8 as isize);
12+
let _ = ptr.offset(offset_usize as isize);
13+
let _ = ptr.offset(offset_isize as isize);
14+
let _ = ptr.offset(offset_u8 as isize);
1515

16-
ptr.wrapping_offset(offset_usize as isize);
17-
ptr.wrapping_offset(offset_isize as isize);
18-
ptr.wrapping_offset(offset_u8 as isize);
16+
let _ = ptr.wrapping_offset(offset_usize as isize);
17+
let _ = ptr.wrapping_offset(offset_isize as isize);
18+
let _ = ptr.wrapping_offset(offset_u8 as isize);
1919
}
2020
}

tests/ui/ptr_offset_with_cast.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
error: use of `offset` with a `usize` casted to an `isize`
2-
--> $DIR/ptr_offset_with_cast.rs:12:9
2+
--> $DIR/ptr_offset_with_cast.rs:12:17
33
|
4-
LL | ptr.offset(offset_usize as isize);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)`
4+
LL | let _ = ptr.offset(offset_usize as isize);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)`
66
|
77
= note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings`
88

99
error: use of `wrapping_offset` with a `usize` casted to an `isize`
10-
--> $DIR/ptr_offset_with_cast.rs:16:9
10+
--> $DIR/ptr_offset_with_cast.rs:16:17
1111
|
12-
LL | ptr.wrapping_offset(offset_usize as isize);
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)`
12+
LL | let _ = ptr.wrapping_offset(offset_usize as isize);
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)`
1414

1515
error: aborting due to 2 previous errors
1616

0 commit comments

Comments
 (0)