Skip to content

Commit 549dd10

Browse files
committed
rustc: Flag {i,u}128 as unsafe for FFI
These don't appear to have a stable ABI as noted in #41799 and the work in compiler-builtins definitely seems to be confirming it!
1 parent ed532c0 commit 549dd10

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: src/librustc_lint/types.rs

+12
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,18 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
543543
`u32` or `libc::wchar_t` should be used")
544544
}
545545

546+
ty::TyInt(ast::IntTy::I128) => {
547+
FfiUnsafe("found Rust type `i128` in foreign module, but \
548+
128-bit integers don't currently have a known \
549+
stable ABI")
550+
}
551+
552+
ty::TyUint(ast::UintTy::U128) => {
553+
FfiUnsafe("found Rust type `u128` in foreign module, but \
554+
128-bit integers don't currently have a known \
555+
stable ABI")
556+
}
557+
546558
// Primitive types with a stable representation.
547559
ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::TyNever => FfiSafe,
548560

Diff for: src/test/compile-fail/lint-ctypes.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
#![deny(improper_ctypes)]
12-
#![feature(libc)]
12+
#![feature(libc, i128_type)]
1313

1414
extern crate libc;
1515

@@ -39,6 +39,8 @@ extern {
3939
pub fn str_type(p: &str); //~ ERROR: found Rust type
4040
pub fn box_type(p: Box<u32>); //~ ERROR found struct without
4141
pub fn char_type(p: char); //~ ERROR found Rust type
42+
pub fn i128_type(p: i128); //~ ERROR found Rust type
43+
pub fn u128_type(p: u128); //~ ERROR found Rust type
4244
pub fn trait_type(p: &Clone); //~ ERROR found Rust trait type
4345
pub fn tuple_type(p: (i32, i32)); //~ ERROR found Rust tuple type
4446
pub fn tuple_type2(p: I32Pair); //~ ERROR found Rust tuple type

0 commit comments

Comments
 (0)