Use the correct char type on all platforms
This commit is contained in:
parent
5f6390f947
commit
25806f8d80
3 changed files with 8 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
error[E0741]: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-72352.rs:7:42
|
||||
--> $DIR/issue-72352.rs:8:42
|
||||
|
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-72352.rs:7:42
|
||||
--> $DIR/issue-72352.rs:8:42
|
||||
|
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(adt_const_params))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
|
||||
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
F(CStr::from_ptr(ptr))
|
||||
}
|
||||
|
@ -16,7 +17,5 @@ fn safely_do_the_thing(s: &CStr) -> usize {
|
|||
fn main() {
|
||||
let baguette = CString::new("baguette").unwrap();
|
||||
let ptr = baguette.as_ptr();
|
||||
println!("{}", unsafe {
|
||||
unsafely_do_the_thing::<safely_do_the_thing>(ptr)
|
||||
});
|
||||
println!("{}", unsafe { unsafely_do_the_thing::<safely_do_the_thing>(ptr) });
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue