Skip to content

Commit 25806f8

Browse files
committed
Use the correct char type on all platforms
1 parent 5f6390f commit 25806f8

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

tests/ui/const-generics/issues/issue-72352.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0741]: using function pointers as const generic parameters is forbidden
2-
--> $DIR/issue-72352.rs:7:42
2+
--> $DIR/issue-72352.rs:8:42
33
|
4-
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
4+
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
55
| ^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error

tests/ui/const-generics/issues/issue-72352.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: using function pointers as const generic parameters is forbidden
2-
--> $DIR/issue-72352.rs:7:42
2+
--> $DIR/issue-72352.rs:8:42
33
|
4-
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
4+
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
55
| ^^^^^^^^^^^^^^^^^^
66
|
77
= note: the only supported types are integers, `bool` and `char`
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// revisions: full min
2+
23
#![cfg_attr(full, feature(adt_const_params))]
34
#![cfg_attr(full, allow(incomplete_features))]
45

5-
use std::ffi::{CStr, CString};
6+
use std::ffi::{c_char, CStr, CString};
67

7-
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
8+
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
89
//~^ ERROR: using function pointers as const generic parameters is forbidden
910
F(CStr::from_ptr(ptr))
1011
}
@@ -16,7 +17,5 @@ fn safely_do_the_thing(s: &CStr) -> usize {
1617
fn main() {
1718
let baguette = CString::new("baguette").unwrap();
1819
let ptr = baguette.as_ptr();
19-
println!("{}", unsafe {
20-
unsafely_do_the_thing::<safely_do_the_thing>(ptr)
21-
});
20+
println!("{}", unsafe { unsafely_do_the_thing::<safely_do_the_thing>(ptr) });
2221
}

0 commit comments

Comments
 (0)