Skip to content

Commit c4a4294

Browse files
authored
Merge pull request #4525 from xingxue-ibm/no-cast-for-c_char
Cast to `c_char` rather than `i8`
2 parents 0cbd33d + e5f26da commit c4a4294

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

ctest-next/templates/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ mod generated_tests {
5656
let val = {{ ident }};
5757
unsafe {
5858
let ptr = *__test_const_{{ ident }}();
59-
// c_char can be i8 or u8, so just cast to i8.
60-
let val = CStr::from_ptr(ptr.cast::<i8>());
59+
let val = CStr::from_ptr(ptr.cast::<c_char>());
6160
let val = val.to_str().expect("const {{ ident }} not utf8");
6261
let c = ::std::ffi::CStr::from_ptr(ptr as *const _);
6362
let c = c.to_str().expect("const {{ ident }} not utf8");

ctest-next/tests/input/simple.out.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ mod generated_tests {
4949
let val = A;
5050
unsafe {
5151
let ptr = *__test_const_A();
52-
// c_char can be i8 or u8, so just cast to i8.
53-
let val = CStr::from_ptr(ptr.cast::<i8>());
52+
let val = CStr::from_ptr(ptr.cast::<c_char>());
5453
let val = val.to_str().expect("const A not utf8");
5554
let c = ::std::ffi::CStr::from_ptr(ptr as *const _);
5655
let c = c.to_str().expect("const A not utf8");

0 commit comments

Comments
 (0)