-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analyze: add adjust_unsize test case
- Loading branch information
1 parent
b57fa64
commit c096a7f
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ macro_rules! define_tests { | |
|
||
define_tests! { | ||
addr_of, | ||
adjust_unsize, | ||
aggregate1, | ||
algo_md5, | ||
alias1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
// CHECK-LABEL: unsafe fn f | ||
// CHECK-SAME: <'[[LT:[a-z0-9]+]]>(p: &'[[LT]] mut (u8)) { | ||
unsafe fn f(p: *mut u8) { | ||
*p = 1; | ||
} | ||
|
||
// CHECK-LABEL: unsafe fn pass_arr_simple() | ||
unsafe fn pass_arr_simple() { | ||
let mut arr: [u8; 3] = [0; 3]; | ||
// CHECK: f(&mut (&mut (arr) as &mut [u8])[0]); | ||
f(arr.as_mut_ptr()); | ||
} | ||
|
||
// CHECK-LABEL: unsafe fn pass_arr_explicit_ref() | ||
unsafe fn pass_arr_explicit_ref() { | ||
let mut arr: [u8; 3] = [0; 3]; | ||
// CHECK: f(&mut (&mut *((&mut arr)) as &mut [u8])[0]); | ||
f((&mut arr).as_mut_ptr()); | ||
} | ||
|
||
// CHECK-LABEL: unsafe fn pass_arr_ufcs() | ||
unsafe fn pass_arr_ufcs() { | ||
let mut arr: [u8; 3] = [0; 3]; | ||
// CHECK: f(&mut (&mut *(&mut arr) as &mut [u8])[0]); | ||
f(<[_]>::as_mut_ptr(&mut arr)); | ||
} | ||
|