File tree Expand file tree Collapse file tree 3 files changed +18
-18
lines changed Expand file tree Collapse file tree 3 files changed +18
-18
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 11error: 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
99error: 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
1515error: aborting due to 2 previous errors
1616
You can’t perform that action at this time.
0 commit comments