This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
tests/ui/const-generics/issues Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 11error[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
77error: aborting due to 1 previous error
Original file line number Diff line number Diff line change 11error: 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 number Diff line number Diff line change 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 {
1617fn 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}
You can’t perform that action at this time.
0 commit comments