Skip to content

Commit

Permalink
Use the correct char type on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 14, 2024
1 parent 5f6390f commit 25806f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/ui/const-generics/issues/issue-72352.full.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/const-generics/issues/issue-72352.min.stderr
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
9 changes: 4 additions & 5 deletions tests/ui/const-generics/issues/issue-72352.rs
Original file line number Diff line number Diff line change
@@ -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))
}
Expand All @@ -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) });
}

0 comments on commit 25806f8

Please sign in to comment.