Skip to content

Commit 426da6c

Browse files
committed
Don't warn when |usize| and |isize| are used in FFI declarations.
It is safer to alias |size_t|/|ssize_t| as |usize|/|size_t| on platforms where they are the same size, in order to reduce unneccessary and hazardous casting. In theory, there are platforms where |usize| and |isize| are not the same as |size_t| and |ssize_t|, and in that case we **should** have this warning, but we don't currently support any such platforms, so we don't bother adding any logic to deal with that situation yet.
1 parent 2dbaccd commit 426da6c

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/librustc_lint/builtin.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
550550
FfiSafe
551551
}
552552

553-
ty::TyInt(ast::TyIs) => {
554-
FfiUnsafe("found Rust type `isize` in foreign module, while \
555-
`libc::c_int` or `libc::c_long` should be used")
556-
}
557-
ty::TyUint(ast::TyUs) => {
558-
FfiUnsafe("found Rust type `usize` in foreign module, while \
559-
`libc::c_uint` or `libc::c_ulong` should be used")
560-
}
553+
// FIXME: We should warn about `usize`/`isize`/ if (and only if)
554+
// `size_t`/'ssize_t' are not defined as aliases for them.
555+
561556
ty::TyChar => {
562557
FfiUnsafe("found Rust type `char` in foreign module, while \
563558
`u32` or `libc::wchar_t` should be used")

0 commit comments

Comments
 (0)