Skip to content

Commit

Permalink
Update test after const_ptr functions are must_use now
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed May 20, 2020
1 parent b8098fe commit da9b138
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions tests/ui/ptr_offset_with_cast.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ fn main() {
let offset_isize = 1_isize;

unsafe {
ptr.add(offset_usize);
ptr.offset(offset_isize as isize);
ptr.offset(offset_u8 as isize);
let _ = ptr.add(offset_usize);
let _ = ptr.offset(offset_isize as isize);
let _ = ptr.offset(offset_u8 as isize);

ptr.wrapping_add(offset_usize);
ptr.wrapping_offset(offset_isize as isize);
ptr.wrapping_offset(offset_u8 as isize);
let _ = ptr.wrapping_add(offset_usize);
let _ = ptr.wrapping_offset(offset_isize as isize);
let _ = ptr.wrapping_offset(offset_u8 as isize);
}
}
12 changes: 6 additions & 6 deletions tests/ui/ptr_offset_with_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ fn main() {
let offset_isize = 1_isize;

unsafe {
ptr.offset(offset_usize as isize);
ptr.offset(offset_isize as isize);
ptr.offset(offset_u8 as isize);
let _ = ptr.offset(offset_usize as isize);
let _ = ptr.offset(offset_isize as isize);
let _ = ptr.offset(offset_u8 as isize);

ptr.wrapping_offset(offset_usize as isize);
ptr.wrapping_offset(offset_isize as isize);
ptr.wrapping_offset(offset_u8 as isize);
let _ = ptr.wrapping_offset(offset_usize as isize);
let _ = ptr.wrapping_offset(offset_isize as isize);
let _ = ptr.wrapping_offset(offset_u8 as isize);
}
}
12 changes: 6 additions & 6 deletions tests/ui/ptr_offset_with_cast.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: use of `offset` with a `usize` casted to an `isize`
--> $DIR/ptr_offset_with_cast.rs:12:9
--> $DIR/ptr_offset_with_cast.rs:12:17
|
LL | ptr.offset(offset_usize as isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)`
LL | let _ = ptr.offset(offset_usize as isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)`
|
= note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings`

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

error: aborting due to 2 previous errors

0 comments on commit da9b138

Please sign in to comment.