Skip to content

Commit f1caa10

Browse files
author
bors-servo
authored
Auto merge of #513 - emilio:const-fn-arg, r=fitzgen
Use the constness of the inner type when converting array function args. Fixes #509 I'm actually surprised we had no tests for this.
2 parents 696e2bb + af6d59c commit f1caa10

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/codegen/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,7 @@ mod utils {
28282828
// [1]: http://c0x.coding-guidelines.com/6.7.5.3.html
28292829
let arg_ty = match *arg_ty.canonical_type(ctx).kind() {
28302830
TypeKind::Array(t, _) => {
2831-
t.to_rust_ty(ctx).to_ptr(arg_ty.is_const(), ctx.span())
2831+
t.to_rust_ty(ctx).to_ptr(ctx.resolve_type(t).is_const(), ctx.span())
28322832
},
28332833
TypeKind::Pointer(inner) => {
28342834
let inner = ctx.resolve_item(inner);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
extern "C" {
8+
pub fn f(a: *const ::std::os::raw::c_int);
9+
}

tests/headers/const_array_fn_arg.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void f(const int a[]);

0 commit comments

Comments
 (0)