Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions c2rust-transpile/src/translator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,7 @@ impl<'c> Translation<'c> {
};
}

let mk_ = mk_.unsafety(extern_block_unsafety(self.tcfg.edition));
let function_decl = mk_.fn_foreign_item(decl);

Ok(ConvertedDecl::ForeignItem(function_decl))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/os-specific/call_only_once.2024.linux.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn __assert_fail(
unsafe fn __assert_fail(
__assertion: *const ::core::ffi::c_char,
__file: *const ::core::ffi::c_char,
__line: ::core::ffi::c_uint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/os-specific/call_only_once.2024.macos.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn __assert_rtn(
unsafe fn __assert_rtn(
_: *const ::core::ffi::c_char,
_: *const ::core::ffi::c_char,
_: ::core::ffi::c_int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/exprs.2024.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn puts(str: *const ::core::ffi::c_char) -> ::core::ffi::c_int;
unsafe fn puts(str: *const ::core::ffi::c_char) -> ::core::ffi::c_int;
}
pub type C2Rust_Unnamed = ::core::ffi::c_uint;
pub const C: C2Rust_Unnamed = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ expression: cat tests/snapshots/os-specific/macros.2024.linux.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn __errno_location() -> *mut ::core::ffi::c_int;
fn memcpy(
unsafe fn __errno_location() -> *mut ::core::ffi::c_int;
unsafe fn memcpy(
__dest: *mut ::core::ffi::c_void,
__src: *const ::core::ffi::c_void,
__n: size_t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ expression: cat tests/snapshots/os-specific/macros.2024.macos.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn __error() -> *mut ::core::ffi::c_int;
fn memcpy(
unsafe fn __error() -> *mut ::core::ffi::c_int;
unsafe fn memcpy(
__dst: *mut ::core::ffi::c_void,
__src: *const ::core::ffi::c_void,
__n: size_t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/macros.2024.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn extern_fn() -> ::core::ffi::c_int;
unsafe fn extern_fn() -> ::core::ffi::c_int;
}
pub type uintptr_t = usize;
#[derive(Copy, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/os-specific/rnd.2024.linux.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn abs(__x: ::core::ffi::c_int) -> ::core::ffi::c_int;
unsafe fn abs(__x: ::core::ffi::c_int) -> ::core::ffi::c_int;
}
pub type __int32_t = i32;
pub type __uint32_t = u32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/os-specific/rnd.2024.macos.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn abs(_: ::core::ffi::c_int) -> ::core::ffi::c_int;
unsafe fn abs(_: ::core::ffi::c_int) -> ::core::ffi::c_int;
}
pub type int32_t = i32;
pub type uint32_t = u32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/arch-os-specific/varargs.2024.aarch64.macos.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn printf(_: *const ::core::ffi::c_char, ...) -> ::core::ffi::c_int;
unsafe fn printf(_: *const ::core::ffi::c_char, ...) -> ::core::ffi::c_int;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn call_printf() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ expression: cat tests/snapshots/arch-os-specific/varargs.2024.x86_64.linux.rs
#![deny(unsafe_op_in_unsafe_fn)]
#![feature(c_variadic)]
unsafe extern "C" {
fn printf(__format: *const ::core::ffi::c_char, ...) -> ::core::ffi::c_int;
fn vprintf(
unsafe fn printf(__format: *const ::core::ffi::c_char, ...) -> ::core::ffi::c_int;
unsafe fn vprintf(
__format: *const ::core::ffi::c_char,
__arg: ::core::ffi::VaList,
) -> ::core::ffi::c_int;
fn putchar(__c: ::core::ffi::c_int) -> ::core::ffi::c_int;
unsafe fn putchar(__c: ::core::ffi::c_int) -> ::core::ffi::c_int;
}
pub type __builtin_va_list = [__va_list_tag; 1];
#[derive(Copy, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/os-specific/wide_strings.2024.linux.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn wcslen(__s: *const wchar_t) -> ::core::ffi::c_ulong;
unsafe fn wcslen(__s: *const wchar_t) -> ::core::ffi::c_ulong;
}
pub type size_t = usize;
pub type wchar_t = ::libc::wchar_t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ expression: cat tests/snapshots/os-specific/wide_strings.2024.macos.rs
)]
#![deny(unsafe_op_in_unsafe_fn)]
unsafe extern "C" {
fn wcslen(_: *const wchar_t) -> ::core::ffi::c_ulong;
unsafe fn wcslen(_: *const wchar_t) -> ::core::ffi::c_ulong;
}
pub type __darwin_size_t = usize;
pub type __darwin_wchar_t = ::libc::wchar_t;
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/items/src/test_fn_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ unsafe extern "C" fn rust_gnu_inline_non_canonical_definition_extern
r#"
unsafe extern "C" {{
#[link_name = "inline_extern"]
{}fn aliased_fn();
"#,
public
{public}unsafe fn aliased_fn();
"#
)
};
assert!(
Expand Down
Loading