Skip to content

Commit ab7f6fc

Browse files
thunderseethecopybara-github
authored andcommitted
Disable HIR types.
Fix up our existing primitive types test. It relies on `core::ffi:primitives` which will no longer behave correctly. It's been migrated to use ffi_11 which will be the only supported path moving forward. PiperOrigin-RevId: 840301985
1 parent e91ac5b commit ab7f6fc

File tree

7 files changed

+98
-84
lines changed

7 files changed

+98
-84
lines changed

cc_bindings_from_rs/cmdline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub struct Cmdline {
145145

146146
/// Feature flag for HIR types. When enabled, we will query the HIR for type sugar that does
147147
/// not appear in MIR types and use it to generate bindings.
148-
#[clap(long, value_parser, value_name = "BOOL", default_value_t = true)]
148+
#[clap(long, value_parser, value_name = "BOOL", default_value_t = false)]
149149
pub enable_hir_types: bool,
150150

151151
/// Emit extra source information for generating cross-references.

cc_bindings_from_rs/test/consts/consts_cc_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static constexpr std::int64_t LARGE_INT = INT64_C(9223372036854775807);
5353
static constexpr std::uint32_t UNSIGNED_INT = UINT32_C(4294967295);
5454
static constexpr std::uintptr_t SLICE_LENGTH = 11;
5555
static constexpr std::intptr_t ISIZE = INT64_C(42);
56-
static constexpr char CHAR = 42;
56+
static constexpr std::int8_t CHAR = 42;
5757
// Generated from:
5858
// cc_bindings_from_rs/test/consts/consts.rs;l=49
5959
struct CRUBIT_INTERNAL_RUST_TYPE(

cc_bindings_from_rs/test/primitive_types/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ rust_library(
2121
aspect_hints = [
2222
"//features:experimental",
2323
],
24-
deps = ["@crate_index//:libc"], # v0_2
24+
deps = [
25+
"//support/ffi_11",
26+
"@crate_index//:libc", # v0_2
27+
],
2528
)
2629

2730
cc_bindings_from_rust(

cc_bindings_from_rs/test/primitive_types/primitive_types.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

55
pub mod test_c_void_ptr {
6-
use core::ffi::c_void;
6+
use ffi_11::c_void;
77

88
// As struct member.
99
pub struct StructWithCVoidPointerMember {
@@ -51,17 +51,17 @@ pub mod test_maybe_uninit {
5151
}
5252

5353
extern "C" fn i8_func(_: i8) {}
54-
extern "C" fn c_char_func(_: core::ffi::c_char) {}
54+
extern "C" fn c_char_func(_: ffi_11::c_char) {}
5555

5656
pub mod argument_types {
57-
use core::ffi;
57+
use ffi_11 as ffi;
5858

5959
pub fn c_char_ptr_arg(_: *const ffi::c_char) {}
6060
pub fn c_char_mut_ptr_arg(_: *mut ffi::c_char) {}
6161
}
6262

6363
pub mod return_types {
64-
use core::ffi;
64+
use ffi_11 as ffi;
6565

6666
pub fn c_void() {}
6767
pub fn c_void_mut_ptr() -> *mut ffi::c_void {
@@ -72,7 +72,7 @@ pub mod return_types {
7272
}
7373

7474
pub fn c_char() -> ffi::c_char {
75-
0
75+
ffi_11::c_char::from(0i8)
7676
}
7777
pub fn c_char_mut_ptr() -> *mut ffi::c_char {
7878
core::ptr::null_mut()
@@ -82,34 +82,34 @@ pub mod return_types {
8282
}
8383

8484
pub fn c_schar() -> ffi::c_schar {
85-
0
85+
0i8
8686
}
8787
pub fn c_uchar() -> ffi::c_uchar {
88-
0
88+
0u8
8989
}
9090
pub fn c_short() -> ffi::c_short {
91-
0
91+
0i16
9292
}
9393
pub fn c_ushort() -> ffi::c_ushort {
94-
0
94+
0u16
9595
}
9696
pub fn c_int() -> ffi::c_int {
9797
0
9898
}
9999
pub fn c_uint() -> ffi::c_uint {
100-
0
100+
0u32
101101
}
102102
pub fn c_long() -> ffi::c_long {
103-
0
103+
0.into()
104104
}
105105
pub fn c_ulong() -> ffi::c_ulong {
106-
0
106+
0u32.into()
107107
}
108108
pub fn c_longlong() -> ffi::c_longlong {
109-
0
109+
0i64.into()
110110
}
111111
pub fn c_ulonglong() -> ffi::c_ulonglong {
112-
0
112+
0u64.into()
113113
}
114114
pub fn c_float() -> ffi::c_float {
115115
0.0
@@ -165,7 +165,7 @@ pub mod return_types {
165165
}
166166

167167
pub mod field_types {
168-
use core::ffi;
168+
use ffi_11 as ffi;
169169
pub struct Types {
170170
pub c_void_mut_ptr: *mut ffi::c_void,
171171
pub c_void_const_ptr: *const ffi::c_void,

0 commit comments

Comments
 (0)