Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4614671c
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4614671c
编写于
9月 01, 2020
作者:
M
Mark Rousskov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update code to account for extern ABI requirement
上级
920b5ee7
变更
78
显示空白变更内容
内联
并排
Showing
78 changed file
with
155 addition
and
166 deletion
+155
-166
compiler/rustc_error_codes/src/error_codes/E0633.md
compiler/rustc_error_codes/src/error_codes/E0633.md
+1
-1
library/std/src/keyword_docs.rs
library/std/src/keyword_docs.rs
+1
-1
library/std/src/sys/unix/weak.rs
library/std/src/sys/unix/weak.rs
+1
-1
src/test/codegen/debug-linkage-name.rs
src/test/codegen/debug-linkage-name.rs
+3
-3
src/test/codegen/export-no-mangle.rs
src/test/codegen/export-no-mangle.rs
+4
-4
src/test/codegen/issue-47278.rs
src/test/codegen/issue-47278.rs
+1
-1
src/test/codegen/repr-transparent-aggregates-1.rs
src/test/codegen/repr-transparent-aggregates-1.rs
+8
-8
src/test/codegen/repr-transparent.rs
src/test/codegen/repr-transparent.rs
+17
-17
src/test/codegen/target-cpu-on-functions.rs
src/test/codegen/target-cpu-on-functions.rs
+1
-1
src/test/codegen/unwind-extern-exports.rs
src/test/codegen/unwind-extern-exports.rs
+1
-1
src/test/incremental/hashes/inherent_impls.rs
src/test/incremental/hashes/inherent_impls.rs
+1
-1
src/test/incremental/hashes/trait_defs.rs
src/test/incremental/hashes/trait_defs.rs
+1
-1
src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs
src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs
+2
-2
src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs
src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs
+1
-1
src/test/run-make-fulldeps/cdylib/foo.rs
src/test/run-make-fulldeps/cdylib/foo.rs
+2
-2
src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs
...-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs
+1
-1
src/test/run-make-fulldeps/glibc-staticlib-args/library.rs
src/test/run-make-fulldeps/glibc-staticlib-args/library.rs
+1
-1
src/test/run-make-fulldeps/issue-14500/foo.rs
src/test/run-make-fulldeps/issue-14500/foo.rs
+1
-1
src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs
src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs
+1
-1
src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs
src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs
+1
-1
src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs
...est/run-make-fulldeps/sanitizer-staticlib-link/library.rs
+1
-1
src/test/run-make-fulldeps/static-dylib-by-default/bar.rs
src/test/run-make-fulldeps/static-dylib-by-default/bar.rs
+1
-1
src/test/run-make-fulldeps/std-core-cycle/foo.rs
src/test/run-make-fulldeps/std-core-cycle/foo.rs
+1
-1
src/test/ui/abi/extern/extern-call-direct.rs
src/test/ui/abi/extern/extern-call-direct.rs
+1
-1
src/test/ui/auxiliary/lto-duplicate-symbols1.rs
src/test/ui/auxiliary/lto-duplicate-symbols1.rs
+1
-1
src/test/ui/auxiliary/lto-duplicate-symbols2.rs
src/test/ui/auxiliary/lto-duplicate-symbols2.rs
+1
-1
src/test/ui/consts/auxiliary/cci_const.rs
src/test/ui/consts/auxiliary/cci_const.rs
+1
-1
src/test/ui/consts/auxiliary/issue-63226.rs
src/test/ui/consts/auxiliary/issue-63226.rs
+2
-2
src/test/ui/consts/const-cast.rs
src/test/ui/consts/const-cast.rs
+1
-1
src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs
.../consts/const-extern-fn/const-extern-fn-call-extern-fn.rs
+3
-3
src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs
...ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs
+2
-2
src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr
...onsts/const-extern-fn/const-extern-fn-min-const-fn.stderr
+3
-3
src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
...consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
+1
-1
src/test/ui/consts/const-extern-fn/const-extern-fn.rs
src/test/ui/consts/const-extern-fn/const-extern-fn.rs
+6
-6
src/test/ui/consts/const-extern-function.rs
src/test/ui/consts/const-extern-function.rs
+1
-1
src/test/ui/cross-crate/auxiliary/cci_const.rs
src/test/ui/cross-crate/auxiliary/cci_const.rs
+1
-1
src/test/ui/duplicate/dupe-symbols-2.rs
src/test/ui/duplicate/dupe-symbols-2.rs
+2
-2
src/test/ui/duplicate/dupe-symbols-2.stderr
src/test/ui/duplicate/dupe-symbols-2.stderr
+2
-2
src/test/ui/extern/auxiliary/extern-take-value.rs
src/test/ui/extern/auxiliary/extern-take-value.rs
+4
-4
src/test/ui/extern/auxiliary/extern_calling_convention.rs
src/test/ui/extern/auxiliary/extern_calling_convention.rs
+1
-1
src/test/ui/extern/extern-1.rs
src/test/ui/extern/extern-1.rs
+1
-1
src/test/ui/extern/extern-compare-with-return-type.rs
src/test/ui/extern/extern-compare-with-return-type.rs
+10
-10
src/test/ui/extern/extern-main-fn.rs
src/test/ui/extern/extern-main-fn.rs
+1
-1
src/test/ui/extern/extern-main-fn.stderr
src/test/ui/extern/extern-main-fn.stderr
+2
-2
src/test/ui/extern/extern-methods.rs
src/test/ui/extern/extern-methods.rs
+2
-2
src/test/ui/extern/extern-rust.rs
src/test/ui/extern/extern-rust.rs
+1
-1
src/test/ui/extern/extern-wrong-value-type.rs
src/test/ui/extern/extern-wrong-value-type.rs
+1
-1
src/test/ui/extern/issue-10025.rs
src/test/ui/extern/issue-10025.rs
+1
-1
src/test/ui/functions-closures/auxiliary/fn-abi.rs
src/test/ui/functions-closures/auxiliary/fn-abi.rs
+1
-1
src/test/ui/generics/generic-no-mangle.fixed
src/test/ui/generics/generic-no-mangle.fixed
+1
-1
src/test/ui/generics/generic-no-mangle.rs
src/test/ui/generics/generic-no-mangle.rs
+1
-1
src/test/ui/generics/generic-no-mangle.stderr
src/test/ui/generics/generic-no-mangle.stderr
+2
-2
src/test/ui/hashmap/hashmap-memory.rs
src/test/ui/hashmap/hashmap-memory.rs
+1
-1
src/test/ui/issues/auxiliary/issue-13620-1.rs
src/test/ui/issues/auxiliary/issue-13620-1.rs
+2
-2
src/test/ui/issues/issue-10764.rs
src/test/ui/issues/issue-10764.rs
+1
-1
src/test/ui/issues/issue-15562.rs
src/test/ui/issues/issue-15562.rs
+1
-1
src/test/ui/issues/issue-26997.rs
src/test/ui/issues/issue-26997.rs
+1
-1
src/test/ui/issues/issue-28600.rs
src/test/ui/issues/issue-28600.rs
+1
-1
src/test/ui/issues/issue-51907.rs
src/test/ui/issues/issue-51907.rs
+4
-4
src/test/ui/lint/lint-ctypes-fn.rs
src/test/ui/lint/lint-ctypes-fn.rs
+4
-4
src/test/ui/mir/mir_codegen_calls.rs
src/test/ui/mir/mir_codegen_calls.rs
+1
-1
src/test/ui/no_owned_box_lang_item.rs
src/test/ui/no_owned_box_lang_item.rs
+1
-1
src/test/ui/nullable-pointer-size.rs
src/test/ui/nullable-pointer-size.rs
+1
-1
src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs
src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs
+3
-3
src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs
src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs
+3
-3
src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs
src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs
+3
-3
src/test/ui/parser/bad-lit-suffixes.stderr
src/test/ui/parser/bad-lit-suffixes.stderr
+1
-12
src/test/ui/proc-macro/signature.rs
src/test/ui/proc-macro/signature.rs
+1
-1
src/test/ui/proc-macro/signature.stderr
src/test/ui/proc-macro/signature.stderr
+1
-1
src/test/ui/proc-macro/span-preservation.rs
src/test/ui/proc-macro/span-preservation.rs
+1
-1
src/test/ui/proc-macro/span-preservation.stderr
src/test/ui/proc-macro/span-preservation.stderr
+2
-2
src/test/ui/range/issue-54505-no-std.rs
src/test/ui/range/issue-54505-no-std.rs
+1
-1
src/test/ui/signal-alternate-stack-cleanup.rs
src/test/ui/signal-alternate-stack-cleanup.rs
+2
-2
src/test/ui/structs-enums/class-dtor.rs
src/test/ui/structs-enums/class-dtor.rs
+2
-2
src/test/ui/symbol-names/impl1.rs
src/test/ui/symbol-names/impl1.rs
+1
-1
src/test/ui/type-param.rs
src/test/ui/type-param.rs
+1
-1
src/test/ui/type-params-in-for-each.rs
src/test/ui/type-params-in-for-each.rs
+1
-1
src/test/ui/unique/unique-ffi-symbols.rs
src/test/ui/unique/unique-ffi-symbols.rs
+4
-4
未找到文件。
compiler/rustc_error_codes/src/error_codes/E0633.md
浏览文件 @
4614671c
...
...
@@ -6,7 +6,7 @@ Erroneous code example:
#![feature(unwind_attributes)]
#[unwind()] // error: expected one argument
pub extern fn something() {}
pub extern
"C"
fn something() {}
fn main() {}
```
...
...
library/std/src/keyword_docs.rs
浏览文件 @
4614671c
...
...
@@ -401,7 +401,7 @@ mod enum_keyword {}
///
/// ```rust
/// #[no_mangle]
/// pub extern fn callable_from_c(x: i32) -> bool {
/// pub extern
"C"
fn callable_from_c(x: i32) -> bool {
/// x % 3 == 0
/// }
/// ```
...
...
library/std/src/sys/unix/weak.rs
浏览文件 @
4614671c
...
...
@@ -28,7 +28,7 @@
macro_rules!
weak
{
(
fn
$name:ident
(
$
(
$t:ty
),
*
)
->
$ret:ty
)
=>
(
static
$name
:
crate
::
sys
::
weak
::
Weak
<
unsafe
extern
fn
(
$
(
$t
),
*
)
->
$ret
>
=
static
$name
:
crate
::
sys
::
weak
::
Weak
<
unsafe
extern
"C"
fn
(
$
(
$t
),
*
)
->
$ret
>
=
crate
::
sys
::
weak
::
Weak
::
new
(
concat!
(
stringify!
(
$name
),
'\0'
));
)
}
...
...
src/test/codegen/debug-linkage-name.rs
浏览文件 @
4614671c
...
...
@@ -26,17 +26,17 @@ pub mod xyz {
// CHECK: !DISubprogram(name: "e",
// CHECK: linkageName:
// CHECK-SAME: line: 29,
pub
extern
fn
e
()
{}
pub
extern
"C"
fn
e
()
{}
// CHECK: !DISubprogram(name: "f",
// CHECK-NOT: linkageName:
// CHECK-SAME: line: 35,
#[no_mangle]
pub
extern
fn
f
()
{}
pub
extern
"C"
fn
f
()
{}
// CHECK: !DISubprogram(name: "g",
// CHECK-NOT: linkageName:
// CHECK-SAME: line: 41,
#[export_name
=
"g"
]
pub
extern
fn
g
()
{}
pub
extern
"C"
fn
g
()
{}
}
src/test/codegen/export-no-mangle.rs
浏览文件 @
4614671c
...
...
@@ -13,19 +13,19 @@ mod private {
// CHECK: void @a()
#[no_mangle]
pub
extern
fn
a
()
{}
pub
extern
"C"
fn
a
()
{}
// CHECK: void @b()
#[export_name
=
"b"
]
extern
fn
b
()
{}
extern
"C"
fn
b
()
{}
// CHECK: void @c()
#[export_name
=
"c"
]
#[inline]
extern
fn
c
()
{}
extern
"C"
fn
c
()
{}
// CHECK: void @d()
#[export_name
=
"d"
]
#[inline(always)]
extern
fn
d
()
{}
extern
"C"
fn
d
()
{}
}
src/test/codegen/issue-47278.rs
浏览文件 @
4614671c
...
...
@@ -6,4 +6,4 @@
// CHECK: define {{.*}} @foo(
#[no_mangle]
pub
extern
fn
foo
(
_
:
Foo
)
->
Foo
{
loop
{}
}
pub
extern
"C"
fn
foo
(
_
:
Foo
)
->
Foo
{
loop
{}
}
src/test/codegen/repr-transparent-aggregates-1.rs
浏览文件 @
4614671c
...
...
@@ -36,19 +36,19 @@ pub enum TeBigS {
// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], %BigS* [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]])
#[no_mangle]
pub
extern
fn
test_BigS
(
_
:
BigS
)
->
BigS
{
loop
{}
}
pub
extern
"C"
fn
test_BigS
(
_
:
BigS
)
->
BigS
{
loop
{}
}
// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], %TsBigS* [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]])
#[no_mangle]
pub
extern
fn
test_TsBigS
(
_
:
TsBigS
)
->
TsBigS
{
loop
{}
}
pub
extern
"C"
fn
test_TsBigS
(
_
:
TsBigS
)
->
TsBigS
{
loop
{}
}
// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], %TuBigS* [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]])
#[no_mangle]
pub
extern
fn
test_TuBigS
(
_
:
TuBigS
)
->
TuBigS
{
loop
{}
}
pub
extern
"C"
fn
test_TuBigS
(
_
:
TuBigS
)
->
TuBigS
{
loop
{}
}
// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], %"TeBigS::Variant"* [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]])
#[no_mangle]
pub
extern
fn
test_TeBigS
(
_
:
TeBigS
)
->
TeBigS
{
loop
{}
}
pub
extern
"C"
fn
test_TeBigS
(
_
:
TeBigS
)
->
TeBigS
{
loop
{}
}
#[derive(Clone,
Copy)]
...
...
@@ -72,16 +72,16 @@ pub enum TeBigU {
// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], %BigU* [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]])
#[no_mangle]
pub
extern
fn
test_BigU
(
_
:
BigU
)
->
BigU
{
loop
{}
}
pub
extern
"C"
fn
test_BigU
(
_
:
BigU
)
->
BigU
{
loop
{}
}
// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], %TsBigU* [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]])
#[no_mangle]
pub
extern
fn
test_TsBigU
(
_
:
TsBigU
)
->
TsBigU
{
loop
{}
}
pub
extern
"C"
fn
test_TsBigU
(
_
:
TsBigU
)
->
TsBigU
{
loop
{}
}
// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], %TuBigU* [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]])
#[no_mangle]
pub
extern
fn
test_TuBigU
(
_
:
TuBigU
)
->
TuBigU
{
loop
{}
}
pub
extern
"C"
fn
test_TuBigU
(
_
:
TuBigU
)
->
TuBigU
{
loop
{}
}
// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], %"TeBigU::Variant"* [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]])
#[no_mangle]
pub
extern
fn
test_TeBigU
(
_
:
TeBigU
)
->
TeBigU
{
loop
{}
}
pub
extern
"C"
fn
test_TeBigU
(
_
:
TeBigU
)
->
TeBigU
{
loop
{}
}
src/test/codegen/repr-transparent.rs
浏览文件 @
4614671c
...
...
@@ -19,21 +19,21 @@
// CHECK: define float @test_F32(float %_1)
#[no_mangle]
pub
extern
fn
test_F32
(
_
:
F32
)
->
F32
{
loop
{}
}
pub
extern
"C"
fn
test_F32
(
_
:
F32
)
->
F32
{
loop
{}
}
#[repr(transparent)]
pub
struct
Ptr
(
*
mut
u8
);
// CHECK: define i8* @test_Ptr(i8* %_1)
#[no_mangle]
pub
extern
fn
test_Ptr
(
_
:
Ptr
)
->
Ptr
{
loop
{}
}
pub
extern
"C"
fn
test_Ptr
(
_
:
Ptr
)
->
Ptr
{
loop
{}
}
#[repr(transparent)]
pub
struct
WithZst
(
u64
,
Zst1
);
// CHECK: define i64 @test_WithZst(i64 %_1)
#[no_mangle]
pub
extern
fn
test_WithZst
(
_
:
WithZst
)
->
WithZst
{
loop
{}
}
pub
extern
"C"
fn
test_WithZst
(
_
:
WithZst
)
->
WithZst
{
loop
{}
}
#[repr(transparent)]
pub
struct
WithZeroSizedArray
(
*
const
f32
,
[
i8
;
0
]);
...
...
@@ -41,14 +41,14 @@
// Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever.
// CHECK: define i32* @test_WithZeroSizedArray(i32* %_1)
#[no_mangle]
pub
extern
fn
test_WithZeroSizedArray
(
_
:
WithZeroSizedArray
)
->
WithZeroSizedArray
{
loop
{}
}
pub
extern
"C"
fn
test_WithZeroSizedArray
(
_
:
WithZeroSizedArray
)
->
WithZeroSizedArray
{
loop
{}
}
#[repr(transparent)]
pub
struct
Generic
<
T
>
(
T
);
// CHECK: define double @test_Generic(double %_1)
#[no_mangle]
pub
extern
fn
test_Generic
(
_
:
Generic
<
f64
>
)
->
Generic
<
f64
>
{
loop
{}
}
pub
extern
"C"
fn
test_Generic
(
_
:
Generic
<
f64
>
)
->
Generic
<
f64
>
{
loop
{}
}
#[repr(transparent)]
pub
struct
GenericPlusZst
<
T
>
(
T
,
Zst2
);
...
...
@@ -58,14 +58,14 @@ pub enum Bool { True, False, FileNotFound }
// CHECK: define{{( zeroext)?}} i8 @test_Gpz(i8{{( zeroext)?}} %_1)
#[no_mangle]
pub
extern
fn
test_Gpz
(
_
:
GenericPlusZst
<
Bool
>
)
->
GenericPlusZst
<
Bool
>
{
loop
{}
}
pub
extern
"C"
fn
test_Gpz
(
_
:
GenericPlusZst
<
Bool
>
)
->
GenericPlusZst
<
Bool
>
{
loop
{}
}
#[repr(transparent)]
pub
struct
LifetimePhantom
<
'a
,
T
:
'a
>
(
*
const
T
,
PhantomData
<&
'a
T
>
);
// CHECK: define i16* @test_LifetimePhantom(i16* %_1)
#[no_mangle]
pub
extern
fn
test_LifetimePhantom
(
_
:
LifetimePhantom
<
i16
>
)
->
LifetimePhantom
<
i16
>
{
loop
{}
}
pub
extern
"C"
fn
test_LifetimePhantom
(
_
:
LifetimePhantom
<
i16
>
)
->
LifetimePhantom
<
i16
>
{
loop
{}
}
// This works despite current alignment resrictions because PhantomData is always align(1)
#[repr(transparent)]
...
...
@@ -75,28 +75,28 @@ pub struct UnitPhantom<T, U> { val: T, unit: PhantomData<U> }
// CHECK: define float @test_UnitPhantom(float %_1)
#[no_mangle]
pub
extern
fn
test_UnitPhantom
(
_
:
UnitPhantom
<
f32
,
Px
>
)
->
UnitPhantom
<
f32
,
Px
>
{
loop
{}
}
pub
extern
"C"
fn
test_UnitPhantom
(
_
:
UnitPhantom
<
f32
,
Px
>
)
->
UnitPhantom
<
f32
,
Px
>
{
loop
{}
}
#[repr(transparent)]
pub
struct
TwoZsts
(
Zst1
,
i8
,
Zst2
);
// CHECK: define{{( signext)?}} i8 @test_TwoZsts(i8{{( signext)?}} %_1)
#[no_mangle]
pub
extern
fn
test_TwoZsts
(
_
:
TwoZsts
)
->
TwoZsts
{
loop
{}
}
pub
extern
"C"
fn
test_TwoZsts
(
_
:
TwoZsts
)
->
TwoZsts
{
loop
{}
}
#[repr(transparent)]
pub
struct
Nested1
(
Zst2
,
Generic
<
f64
>
);
// CHECK: define double @test_Nested1(double %_1)
#[no_mangle]
pub
extern
fn
test_Nested1
(
_
:
Nested1
)
->
Nested1
{
loop
{}
}
pub
extern
"C"
fn
test_Nested1
(
_
:
Nested1
)
->
Nested1
{
loop
{}
}
#[repr(transparent)]
pub
struct
Nested2
(
Nested1
,
Zst1
);
// CHECK: define double @test_Nested2(double %_1)
#[no_mangle]
pub
extern
fn
test_Nested2
(
_
:
Nested2
)
->
Nested2
{
loop
{}
}
pub
extern
"C"
fn
test_Nested2
(
_
:
Nested2
)
->
Nested2
{
loop
{}
}
#[repr(simd)]
struct
f32x4
(
f32
,
f32
,
f32
,
f32
);
...
...
@@ -106,7 +106,7 @@ pub struct UnitPhantom<T, U> { val: T, unit: PhantomData<U> }
// CHECK: define <4 x float> @test_Vector(<4 x float> %_1)
#[no_mangle]
pub
extern
fn
test_Vector
(
_
:
Vector
)
->
Vector
{
loop
{}
}
pub
extern
"C"
fn
test_Vector
(
_
:
Vector
)
->
Vector
{
loop
{}
}
trait
Mirror
{
type
It
:
?
Sized
;
}
impl
<
T
:
?
Sized
>
Mirror
for
T
{
type
It
=
Self
;
}
...
...
@@ -116,7 +116,7 @@ pub struct UnitPhantom<T, U> { val: T, unit: PhantomData<U> }
// CHECK: define float @test_Projection(float %_1)
#[no_mangle]
pub
extern
fn
test_Projection
(
_
:
StructWithProjection
)
->
StructWithProjection
{
loop
{}
}
pub
extern
"C"
fn
test_Projection
(
_
:
StructWithProjection
)
->
StructWithProjection
{
loop
{}
}
#[repr(transparent)]
pub
enum
EnumF32
{
...
...
@@ -125,7 +125,7 @@ pub enum EnumF32 {
// CHECK: define float @test_EnumF32(float %_1)
#[no_mangle]
pub
extern
fn
test_EnumF32
(
_
:
EnumF32
)
->
EnumF32
{
loop
{}
}
pub
extern
"C"
fn
test_EnumF32
(
_
:
EnumF32
)
->
EnumF32
{
loop
{}
}
#[repr(transparent)]
pub
enum
EnumF32WithZsts
{
...
...
@@ -134,7 +134,7 @@ pub enum EnumF32WithZsts {
// CHECK: define float @test_EnumF32WithZsts(float %_1)
#[no_mangle]
pub
extern
fn
test_EnumF32WithZsts
(
_
:
EnumF32WithZsts
)
->
EnumF32WithZsts
{
loop
{}
}
pub
extern
"C"
fn
test_EnumF32WithZsts
(
_
:
EnumF32WithZsts
)
->
EnumF32WithZsts
{
loop
{}
}
#[repr(transparent)]
pub
union
UnionF32
{
...
...
@@ -143,7 +143,7 @@ pub union UnionF32 {
// CHECK: define float @test_UnionF32(float %_1)
#[no_mangle]
pub
extern
fn
test_UnionF32
(
_
:
UnionF32
)
->
UnionF32
{
loop
{}
}
pub
extern
"C"
fn
test_UnionF32
(
_
:
UnionF32
)
->
UnionF32
{
loop
{}
}
#[repr(transparent)]
pub
union
UnionF32WithZsts
{
...
...
@@ -154,7 +154,7 @@ pub union UnionF32WithZsts {
// CHECK: define float @test_UnionF32WithZsts(float %_1)
#[no_mangle]
pub
extern
fn
test_UnionF32WithZsts
(
_
:
UnionF32WithZsts
)
->
UnionF32WithZsts
{
loop
{}
}
pub
extern
"C"
fn
test_UnionF32WithZsts
(
_
:
UnionF32WithZsts
)
->
UnionF32WithZsts
{
loop
{}
}
// All that remains to be tested are aggregates. They are tested in separate files called repr-
...
...
src/test/codegen/target-cpu-on-functions.rs
浏览文件 @
4614671c
...
...
@@ -9,7 +9,7 @@
// CHECK-LABEL: define {{.*}} @exported() {{.*}} #0
#[no_mangle]
pub
extern
fn
exported
()
{
pub
extern
"C"
fn
exported
()
{
not_exported
();
}
...
...
src/test/codegen/unwind-extern-exports.rs
浏览文件 @
4614671c
...
...
@@ -11,7 +11,7 @@
// "C" ABI
// pub extern fn foo() {} // FIXME right now we don't abort-on-panic but add `nounwind` nevertheless
#[unwind(allowed)]
pub
extern
fn
foo_allowed
()
{}
pub
extern
"C"
fn
foo_allowed
()
{}
// "Rust"
// (`extern "Rust"` could be removed as all `fn` get it implicitly; we leave it in for clarity.)
...
...
src/test/incremental/hashes/inherent_impls.rs
浏览文件 @
4614671c
...
...
@@ -271,7 +271,7 @@ pub fn make_method_extern(&self) { }
impl
Foo
{
#[rustc_clean(cfg=
"cfail2"
,
except=
"hir_owner,hir_owner_nodes,fn_sig,typeck"
)]
#[rustc_clean(cfg=
"cfail3"
)]
pub
extern
fn
make_method_extern
(
&
self
)
{
}
pub
extern
"C"
fn
make_method_extern
(
&
self
)
{
}
}
...
...
src/test/incremental/hashes/trait_defs.rs
浏览文件 @
4614671c
...
...
@@ -312,7 +312,7 @@ trait TraitAddExternModifier {
trait
TraitAddExternModifier
{
#[rustc_dirty(label=
"hir_owner"
,
cfg=
"cfail2"
)]
#[rustc_clean(label=
"hir_owner"
,
cfg=
"cfail3"
)]
extern
fn
method
();
extern
"C"
fn
method
();
}
...
...
src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs
浏览文件 @
4614671c
...
...
@@ -3,11 +3,11 @@
extern
crate
bar
;
#[no_mangle]
pub
extern
fn
foo
()
{
pub
extern
"C"
fn
foo
()
{
bar
::
bar
();
}
#[no_mangle]
pub
extern
fn
bar
(
a
:
u32
,
b
:
u32
)
->
u32
{
pub
extern
"C"
fn
bar
(
a
:
u32
,
b
:
u32
)
->
u32
{
a
+
b
}
src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs
浏览文件 @
4614671c
#![crate_type
=
"cdylib"
]
#[no_mangle]
pub
extern
fn
foo
()
->
u32
{
pub
extern
"C"
fn
foo
()
->
u32
{
3
}
src/test/run-make-fulldeps/cdylib/foo.rs
浏览文件 @
4614671c
...
...
@@ -3,11 +3,11 @@
extern
crate
bar
;
#[no_mangle]
pub
extern
fn
foo
()
{
pub
extern
"C"
fn
foo
()
{
bar
::
bar
();
}
#[no_mangle]
pub
extern
fn
bar
(
a
:
u32
,
b
:
u32
)
->
u32
{
pub
extern
"C"
fn
bar
(
a
:
u32
,
b
:
u32
)
->
u32
{
a
+
b
}
src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs
浏览文件 @
4614671c
...
...
@@ -3,6 +3,6 @@
extern
crate
upstream
;
#[no_mangle]
pub
extern
fn
bar
()
{
pub
extern
"C"
fn
bar
()
{
upstream
::
foo
();
}
src/test/run-make-fulldeps/glibc-staticlib-args/library.rs
浏览文件 @
4614671c
#[no_mangle]
pub
extern
fn
args_check
()
{
pub
extern
"C"
fn
args_check
()
{
assert_ne!
(
std
::
env
::
args_os
()
.count
(),
0
);
}
src/test/run-make-fulldeps/issue-14500/foo.rs
浏览文件 @
4614671c
#[no_mangle]
pub
extern
fn
foo
()
{}
pub
extern
"C"
fn
foo
()
{}
#[no_mangle]
pub
static
FOO_STATIC
:
u8
=
0
;
src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs
浏览文件 @
4614671c
#[no_mangle]
pub
extern
fn
overflow
()
{
pub
extern
"C"
fn
overflow
()
{
let
xs
=
[
0
,
1
,
2
,
3
];
let
_
y
=
unsafe
{
*
xs
.as_ptr
()
.offset
(
4
)
};
}
src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs
浏览文件 @
4614671c
#[no_mangle]
pub
extern
fn
overflow
()
{
pub
extern
"C"
fn
overflow
()
{
let
xs
=
[
0
,
1
,
2
,
3
];
let
_
y
=
unsafe
{
*
xs
.as_ptr
()
.offset
(
4
)
};
}
src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs
浏览文件 @
4614671c
#[no_mangle]
pub
extern
fn
overflow
()
{
pub
extern
"C"
fn
overflow
()
{
let
xs
=
[
0
,
1
,
2
,
3
];
let
_
y
=
unsafe
{
*
xs
.as_ptr
()
.offset
(
4
)
};
}
src/test/run-make-fulldeps/static-dylib-by-default/bar.rs
浏览文件 @
4614671c
...
...
@@ -3,6 +3,6 @@
extern
crate
foo
;
#[no_mangle]
pub
extern
fn
bar
()
{
pub
extern
"C"
fn
bar
()
{
foo
::
foo
();
}
src/test/run-make-fulldeps/std-core-cycle/foo.rs
浏览文件 @
4614671c
...
...
@@ -6,6 +6,6 @@
static
A
:
bar
::
A
=
bar
::
A
;
#[no_mangle]
pub
extern
fn
a
(
a
:
u32
,
b
:
u32
)
->
u32
{
pub
extern
"C"
fn
a
(
a
:
u32
,
b
:
u32
)
->
u32
{
a
/
b
}
src/test/ui/abi/extern/extern-call-direct.rs
浏览文件 @
4614671c
...
...
@@ -2,7 +2,7 @@
// Test direct calls to extern fns.
extern
fn
f
(
x
:
usize
)
->
usize
{
x
*
2
}
extern
"C"
fn
f
(
x
:
usize
)
->
usize
{
x
*
2
}
pub
fn
main
()
{
let
x
=
f
(
22
);
...
...
src/test/ui/auxiliary/lto-duplicate-symbols1.rs
浏览文件 @
4614671c
...
...
@@ -3,4 +3,4 @@
#![crate_type
=
"rlib"
]
#[no_mangle]
pub
extern
fn
foo
()
{}
pub
extern
"C"
fn
foo
()
{}
src/test/ui/auxiliary/lto-duplicate-symbols2.rs
浏览文件 @
4614671c
...
...
@@ -3,4 +3,4 @@
#![crate_type
=
"rlib"
]
#[no_mangle]
pub
extern
fn
foo
()
{}
pub
extern
"C"
fn
foo
()
{}
src/test/ui/consts/auxiliary/cci_const.rs
浏览文件 @
4614671c
pub
extern
fn
bar
()
{
pub
extern
"C"
fn
bar
()
{
}
pub
const
foopy
:
&
'static
str
=
"hi there"
;
...
...
src/test/ui/consts/auxiliary/issue-63226.rs
浏览文件 @
4614671c
pub
struct
VTable
{
state
:
extern
fn
(),
state
:
extern
"C"
fn
(),
}
impl
VTable
{
...
...
@@ -11,4 +11,4 @@ pub const fn vtable()->&'static VTable{
&
VTable
{
state
};
}
extern
fn
state
()
{}
extern
"C"
fn
state
()
{}
src/test/ui/consts/const-cast.rs
浏览文件 @
4614671c
...
...
@@ -7,7 +7,7 @@ struct TestStruct {
unsafe
impl
Sync
for
TestStruct
{}
extern
fn
foo
()
{}
extern
"C"
fn
foo
()
{}
const
x
:
extern
"C"
fn
()
=
foo
;
static
y
:
TestStruct
=
TestStruct
{
x
:
x
as
*
const
u8
};
...
...
src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs
浏览文件 @
4614671c
...
...
@@ -4,16 +4,16 @@
fn
regular_in_block
();
}
const
extern
fn
bar
()
{
const
extern
"C"
fn
bar
()
{
unsafe
{
regular_in_block
();
//~^ ERROR: calls in constant functions
}
}
extern
fn
regular
()
{}
extern
"C"
fn
regular
()
{}
const
extern
fn
foo
()
{
const
extern
"C"
fn
foo
()
{
unsafe
{
regular
();
//~^ ERROR: calls in constant functions
...
...
src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs
浏览文件 @
4614671c
#![feature(const_extern_fn)]
const
extern
fn
unsize
(
x
:
&
[
u8
;
3
])
->
&
[
u8
]
{
x
}
const
extern
"C"
fn
unsize
(
x
:
&
[
u8
;
3
])
->
&
[
u8
]
{
x
}
const
unsafe
extern
"C"
fn
closure
()
->
fn
()
{
||
{}
}
//~^ ERROR function pointer
//~| ERROR function pointer cast
const
unsafe
extern
fn
use_float
()
{
1.0
+
1.0
;
}
const
unsafe
extern
"C"
fn
use_float
()
{
1.0
+
1.0
;
}
//~^ ERROR floating point arithmetic
const
extern
"C"
fn
ptr_cast
(
val
:
*
const
u8
)
{
val
as
usize
;
}
//~^ ERROR casting pointers to integers
...
...
src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr
浏览文件 @
4614671c
...
...
@@ -17,9 +17,9 @@ LL | const unsafe extern "C" fn closure() -> fn() { || {} }
= help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable
error[E0658]: floating point arithmetic is not allowed in constant functions
--> $DIR/const-extern-fn-min-const-fn.rs:7:
38
--> $DIR/const-extern-fn-min-const-fn.rs:7:
42
|
LL | const unsafe extern fn use_float() { 1.0 + 1.0; }
LL | const unsafe extern
"C"
fn use_float() { 1.0 + 1.0; }
| ^^^^^^^^^
|
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information
...
...
src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
浏览文件 @
4614671c
#![feature(const_extern_fn)]
const
unsafe
extern
fn
foo
()
->
usize
{
5
}
const
unsafe
extern
"C"
fn
foo
()
->
usize
{
5
}
fn
main
()
{
let
a
:
[
u8
;
foo
()];
...
...
src/test/ui/consts/const-extern-fn/const-extern-fn.rs
浏览文件 @
4614671c
// run-pass
#![feature(const_extern_fn)]
const
extern
fn
foo1
(
val
:
u8
)
->
u8
{
const
extern
"C"
fn
foo1
(
val
:
u8
)
->
u8
{
val
+
1
}
...
...
@@ -9,7 +9,7 @@
val
+
1
}
const
unsafe
extern
fn
bar1
(
val
:
bool
)
->
bool
{
const
unsafe
extern
"C"
fn
bar1
(
val
:
bool
)
->
bool
{
!
val
}
...
...
@@ -28,8 +28,8 @@ fn main() {
assert
!
(
bar1_res
);
assert_eq!
(
bar1_res
,
bar2_res
);
let
_
foo1_cast
:
extern
fn
(
u8
)
->
u8
=
foo1
;
let
_
foo2_cast
:
extern
fn
(
u8
)
->
u8
=
foo2
;
let
_
bar1_cast
:
unsafe
extern
fn
(
bool
)
->
bool
=
bar1
;
let
_
bar2_cast
:
unsafe
extern
fn
(
bool
)
->
bool
=
bar2
;
let
_
foo1_cast
:
extern
"C"
fn
(
u8
)
->
u8
=
foo1
;
let
_
foo2_cast
:
extern
"C"
fn
(
u8
)
->
u8
=
foo2
;
let
_
bar1_cast
:
unsafe
extern
"C"
fn
(
bool
)
->
bool
=
bar1
;
let
_
bar2_cast
:
unsafe
extern
"C"
fn
(
bool
)
->
bool
=
bar2
;
}
src/test/ui/consts/const-extern-function.rs
浏览文件 @
4614671c
// run-pass
#![allow(non_upper_case_globals)]
extern
fn
foopy
()
{}
extern
"C"
fn
foopy
()
{}
static
f
:
extern
"C"
fn
()
=
foopy
;
static
s
:
S
=
S
{
f
:
foopy
};
...
...
src/test/ui/cross-crate/auxiliary/cci_const.rs
浏览文件 @
4614671c
pub
extern
fn
bar
()
{
pub
extern
"C"
fn
bar
()
{
}
pub
const
foopy
:
&
'static
str
=
"hi there"
;
...
...
src/test/ui/duplicate/dupe-symbols-2.rs
浏览文件 @
4614671c
...
...
@@ -6,13 +6,13 @@
pub
mod
a
{
#[no_mangle]
pub
extern
fn
fail
()
{
pub
extern
"C"
fn
fail
()
{
}
}
pub
mod
b
{
#[no_mangle]
pub
extern
fn
fail
()
{
pub
extern
"C"
fn
fail
()
{
//~^ symbol `fail` is already defined
}
}
src/test/ui/duplicate/dupe-symbols-2.stderr
浏览文件 @
4614671c
error: symbol `fail` is already defined
--> $DIR/dupe-symbols-2.rs:15:5
|
LL | pub extern fn fail() {
| ^^^^^^^^^^^^^^^^^^^^
LL | pub extern
"C"
fn fail() {
| ^^^^^^^^^^^^^^^^^^^^
^^^^
error: aborting due to previous error
src/test/ui/extern/auxiliary/extern-take-value.rs
浏览文件 @
4614671c
pub
extern
fn
f
()
->
i32
{
1
}
pub
extern
fn
g
()
->
i32
{
2
}
pub
extern
"C"
fn
f
()
->
i32
{
1
}
pub
extern
"C"
fn
g
()
->
i32
{
2
}
pub
fn
get_f
()
->
extern
fn
()
->
i32
{
f
}
pub
fn
get_g
()
->
extern
fn
()
->
i32
{
g
}
pub
fn
get_f
()
->
extern
"C"
fn
()
->
i32
{
f
}
pub
fn
get_g
()
->
extern
"C"
fn
()
->
i32
{
g
}
src/test/ui/extern/auxiliary/extern_calling_convention.rs
浏览文件 @
4614671c
...
...
@@ -15,7 +15,7 @@ pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) {
#[inline(never)]
#[cfg(not(target_arch
=
"x86_64"
))]
pub
extern
fn
foo
(
a
:
isize
,
b
:
isize
,
c
:
isize
,
d
:
isize
)
{
pub
extern
"C"
fn
foo
(
a
:
isize
,
b
:
isize
,
c
:
isize
,
d
:
isize
)
{
assert_eq!
(
a
,
1
);
assert_eq!
(
b
,
2
);
assert_eq!
(
c
,
3
);
...
...
src/test/ui/extern/extern-1.rs
浏览文件 @
4614671c
...
...
@@ -2,7 +2,7 @@
#![allow(dead_code)]
// pretty-expanded FIXME #23616
extern
fn
f
()
{
extern
"C"
fn
f
()
{
}
pub
fn
main
()
{
...
...
src/test/ui/extern/extern-compare-with-return-type.rs
浏览文件 @
4614671c
...
...
@@ -3,23 +3,23 @@
#![allow(non_camel_case_types)]
// `dbg!()` differentiates these functions to ensure they won't be merged.
extern
fn
voidret1
()
{
dbg!
()
}
extern
fn
voidret2
()
{
dbg!
()
}
extern
"C"
fn
voidret1
()
{
dbg!
()
}
extern
"C"
fn
voidret2
()
{
dbg!
()
}
extern
fn
uintret
()
->
usize
{
22
}
extern
"C"
fn
uintret
()
->
usize
{
22
}
extern
fn
uintvoidret
(
_
x
:
usize
)
{}
extern
"C"
fn
uintvoidret
(
_
x
:
usize
)
{}
extern
fn
uintuintuintuintret
(
x
:
usize
,
y
:
usize
,
z
:
usize
)
->
usize
{
x
+
y
+
z
}
type
uintuintuintuintret
=
extern
fn
(
usize
,
usize
,
usize
)
->
usize
;
extern
"C"
fn
uintuintuintuintret
(
x
:
usize
,
y
:
usize
,
z
:
usize
)
->
usize
{
x
+
y
+
z
}
type
uintuintuintuintret
=
extern
"C"
fn
(
usize
,
usize
,
usize
)
->
usize
;
pub
fn
main
()
{
assert
!
(
voidret1
as
extern
fn
()
==
voidret1
as
extern
fn
());
assert
!
(
voidret1
as
extern
fn
()
!=
voidret2
as
extern
fn
());
assert
!
(
voidret1
as
extern
"C"
fn
()
==
voidret1
as
extern
"C"
fn
());
assert
!
(
voidret1
as
extern
"C"
fn
()
!=
voidret2
as
extern
"C"
fn
());
assert
!
(
uintret
as
extern
fn
()
->
usize
==
uintret
as
extern
fn
()
->
usize
);
assert
!
(
uintret
as
extern
"C"
fn
()
->
usize
==
uintret
as
extern
"C"
fn
()
->
usize
);
assert
!
(
uintvoidret
as
extern
fn
(
usize
)
==
uintvoidret
as
extern
fn
(
usize
));
assert
!
(
uintvoidret
as
extern
"C"
fn
(
usize
)
==
uintvoidret
as
extern
"C"
fn
(
usize
));
assert
!
(
uintuintuintuintret
as
uintuintuintuintret
==
uintuintuintuintret
as
uintuintuintuintret
);
...
...
src/test/ui/extern/extern-main-fn.rs
浏览文件 @
4614671c
extern
fn
main
()
{}
//~ ERROR: `main` function has wrong type [E0580]
extern
"C"
fn
main
()
{}
//~ ERROR: `main` function has wrong type [E0580]
src/test/ui/extern/extern-main-fn.stderr
浏览文件 @
4614671c
error[E0580]: `main` function has wrong type
--> $DIR/extern-main-fn.rs:1:1
|
LL | extern fn main() {}
| ^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn
LL | extern
"C"
fn main() {}
| ^^^^^^^^^^^^^^^^
^^^^
expected "Rust" fn, found "C" fn
|
= note: expected fn pointer `fn()`
found fn pointer `extern "C" fn()`
...
...
src/test/ui/extern/extern-methods.rs
浏览文件 @
4614671c
...
...
@@ -5,7 +5,7 @@
trait
A
{
extern
"fastcall"
fn
test1
(
i
:
i32
);
extern
fn
test2
(
i
:
i32
);
extern
"C"
fn
test2
(
i
:
i32
);
}
struct
S
;
...
...
@@ -19,7 +19,7 @@ impl A for S {
extern
"fastcall"
fn
test1
(
i
:
i32
)
{
assert_eq!
(
i
,
1
);
}
extern
fn
test2
(
i
:
i32
)
{
extern
"C"
fn
test2
(
i
:
i32
)
{
assert_eq!
(
i
,
2
);
}
}
...
...
src/test/ui/extern/extern-rust.rs
浏览文件 @
4614671c
...
...
@@ -5,7 +5,7 @@
pub
struct
Foo
(
u32
);
// ICE trigger, bad handling of differing types between rust and external ABIs
pub
extern
fn
bar
()
->
Foo
{
pub
extern
"C"
fn
bar
()
->
Foo
{
Foo
(
0
)
}
...
...
src/test/ui/extern/extern-wrong-value-type.rs
浏览文件 @
4614671c
extern
fn
f
()
{
extern
"C"
fn
f
()
{
}
fn
is_fn
<
F
>
(
_
:
F
)
where
F
:
Fn
()
{}
...
...
src/test/ui/extern/issue-10025.rs
浏览文件 @
4614671c
// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![allow(dead_code)]
unsafe
extern
fn
foo
()
{}
unsafe
extern
"C"
fn
bar
()
{}
...
...
src/test/ui/functions-closures/auxiliary/fn-abi.rs
浏览文件 @
4614671c
#[no_mangle]
pub
extern
fn
foo
()
{}
pub
extern
"C"
fn
foo
()
{}
src/test/ui/generics/generic-no-mangle.fixed
浏览文件 @
4614671c
...
...
@@ -6,7 +6,7 @@
pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
pub extern fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
pub extern
"C"
fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub fn baz(x: &i32) -> &i32 { x }
...
...
src/test/ui/generics/generic-no-mangle.rs
浏览文件 @
4614671c
...
...
@@ -6,7 +6,7 @@
pub
fn
foo
<
T
>
()
{}
//~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub
extern
fn
bar
<
T
>
()
{}
//~ ERROR functions generic over types or consts must be mangled
pub
extern
"C"
fn
bar
<
T
>
()
{}
//~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub
fn
baz
(
x
:
&
i32
)
->
&
i32
{
x
}
...
...
src/test/ui/generics/generic-no-mangle.stderr
浏览文件 @
4614671c
...
...
@@ -17,8 +17,8 @@ error: functions generic over types or consts must be mangled
|
LL | #[no_mangle]
| ------------ help: remove this attribute
LL | pub extern fn bar<T>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | pub extern
"C"
fn bar<T>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^
error: aborting due to 2 previous errors
src/test/ui/hashmap/hashmap-memory.rs
浏览文件 @
4614671c
...
...
@@ -23,7 +23,7 @@ mod map_reduce {
pub
type
putter
<
'a
>
=
Box
<
dyn
FnMut
(
String
,
String
)
+
'a
>
;
pub
type
mapper
=
extern
fn
(
String
,
putter
);
pub
type
mapper
=
extern
"C"
fn
(
String
,
putter
);
enum
ctrl_proto
{
find_reducer
(
Vec
<
u8
>
,
Sender
<
isize
>
),
mapper_done
,
}
...
...
src/test/ui/issues/auxiliary/issue-13620-1.rs
浏览文件 @
4614671c
pub
struct
Foo
{
pub
foo
:
extern
fn
()
pub
foo
:
extern
"C"
fn
()
}
extern
fn
the_foo
()
{}
extern
"C"
fn
the_foo
()
{}
pub
const
FOO
:
Foo
=
Foo
{
foo
:
the_foo
...
...
src/test/ui/issues/issue-10764.rs
浏览文件 @
4614671c
fn
f
(
_
:
extern
"Rust"
fn
())
{}
extern
fn
bar
()
{}
extern
"C"
fn
bar
()
{}
fn
main
()
{
f
(
bar
)
}
//~^ ERROR mismatched types
src/test/ui/issues/issue-15562.rs
浏览文件 @
4614671c
...
...
@@ -16,4 +16,4 @@ pub fn main() {
// The above extern is NOT `extern "rust-intrinsic"` and thus
// means it'll try to find a corresponding symbol to link to.
#[no_mangle]
pub
extern
fn
transmute
()
{}
pub
extern
"C"
fn
transmute
()
{}
src/test/ui/issues/issue-26997.rs
浏览文件 @
4614671c
...
...
@@ -7,7 +7,7 @@ pub struct Foo {
impl
Foo
{
#[allow(improper_ctypes_definitions)]
pub
extern
fn
foo_new
()
->
Foo
{
pub
extern
"C"
fn
foo_new
()
->
Foo
{
Foo
{
x
:
21
,
y
:
33
}
}
}
...
...
src/test/ui/issues/issue-28600.rs
浏览文件 @
4614671c
...
...
@@ -7,7 +7,7 @@ impl Test {
#[allow(dead_code)]
#[allow(unused_variables)]
#[allow(improper_ctypes_definitions)]
pub
extern
fn
test
(
val
:
&
str
)
{
pub
extern
"C"
fn
test
(
val
:
&
str
)
{
}
}
...
...
src/test/ui/issues/issue-51907.rs
浏览文件 @
4614671c
// run-pass
trait
Foo
{
extern
fn
borrow
(
&
self
);
extern
fn
take
(
self
:
Box
<
Self
>
);
extern
"C"
fn
borrow
(
&
self
);
extern
"C"
fn
take
(
self
:
Box
<
Self
>
);
}
struct
Bar
;
impl
Foo
for
Bar
{
#[allow(improper_ctypes_definitions)]
extern
fn
borrow
(
&
self
)
{}
extern
"C"
fn
borrow
(
&
self
)
{}
#[allow(improper_ctypes_definitions)]
extern
fn
take
(
self
:
Box
<
Self
>
)
{}
extern
"C"
fn
take
(
self
:
Box
<
Self
>
)
{}
}
fn
main
()
{
...
...
src/test/ui/lint/lint-ctypes-fn.rs
浏览文件 @
4614671c
...
...
@@ -27,7 +27,7 @@ pub struct StructWithProjectionAndLifetime<'a>(
pub
type
RustFn
=
fn
();
pub
type
RustBadRet
=
extern
fn
()
->
Box
<
u32
>
;
pub
type
RustBadRet
=
extern
"C"
fn
()
->
Box
<
u32
>
;
pub
type
CVoidRet
=
();
...
...
@@ -116,7 +116,7 @@ pub extern "C" fn transparent_str(p: TransparentStr) { }
pub
extern
"C"
fn
transparent_fn
(
p
:
TransparentBadFn
)
{
}
pub
extern
"C"
fn
good3
(
fptr
:
Option
<
extern
fn
()
>
)
{
}
pub
extern
"C"
fn
good3
(
fptr
:
Option
<
extern
"C"
fn
()
>
)
{
}
pub
extern
"C"
fn
good4
(
aptr
:
&
[
u8
;
4
as
usize
])
{
}
...
...
@@ -124,9 +124,9 @@ pub extern "C" fn good5(s: StructWithProjection) { }
pub
extern
"C"
fn
good6
(
s
:
StructWithProjectionAndLifetime
)
{
}
pub
extern
"C"
fn
good7
(
fptr
:
extern
fn
()
->
())
{
}
pub
extern
"C"
fn
good7
(
fptr
:
extern
"C"
fn
()
->
())
{
}
pub
extern
"C"
fn
good8
(
fptr
:
extern
fn
()
->
!
)
{
}
pub
extern
"C"
fn
good8
(
fptr
:
extern
"C"
fn
()
->
!
)
{
}
pub
extern
"C"
fn
good9
()
->
()
{
}
...
...
src/test/ui/mir/mir_codegen_calls.rs
浏览文件 @
4614671c
...
...
@@ -75,7 +75,7 @@ fn test8() -> isize {
}
#[allow(improper_ctypes_definitions)]
extern
fn
simple_extern
(
x
:
u32
,
y
:
(
u32
,
u32
))
->
u32
{
extern
"C"
fn
simple_extern
(
x
:
u32
,
y
:
(
u32
,
u32
))
->
u32
{
x
+
y
.0
*
y
.1
}
...
...
src/test/ui/no_owned_box_lang_item.rs
浏览文件 @
4614671c
...
...
@@ -11,6 +11,6 @@ fn main() {
let
x
=
box
1i32
;
}
#[lang
=
"eh_personality"
]
extern
fn
eh_personality
()
{}
#[lang
=
"eh_personality"
]
extern
"C"
fn
eh_personality
()
{}
#[lang
=
"eh_catch_typeinfo"
]
static
EH_CATCH_TYPEINFO
:
u8
=
0
;
#[lang
=
"panic_impl"
]
fn
panic_impl
(
panic
:
&
PanicInfo
)
->
!
{
loop
{}
}
src/test/ui/nullable-pointer-size.rs
浏览文件 @
4614671c
...
...
@@ -31,5 +31,5 @@
pub
fn
main
()
{
check_type!
(
&
'static
isize
);
check_type!
(
Box
<
isize
>
);
check_type!
(
extern
fn
());
check_type!
(
extern
"C"
fn
());
}
src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs
浏览文件 @
4614671c
...
...
@@ -8,10 +8,10 @@
#![panic_runtime]
#[no_mangle]
pub
extern
fn
__
rust_maybe_catch_panic
()
{}
pub
extern
"C"
fn
__
rust_maybe_catch_panic
()
{}
#[no_mangle]
pub
extern
fn
__
rust_start_panic
()
{}
pub
extern
"C"
fn
__
rust_start_panic
()
{}
#[no_mangle]
pub
extern
fn
rust_eh_personality
()
{}
pub
extern
"C"
fn
rust_eh_personality
()
{}
src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs
浏览文件 @
4614671c
...
...
@@ -8,10 +8,10 @@
#![panic_runtime]
#[no_mangle]
pub
extern
fn
__
rust_maybe_catch_panic
()
{}
pub
extern
"C"
fn
__
rust_maybe_catch_panic
()
{}
#[no_mangle]
pub
extern
fn
__
rust_start_panic
()
{}
pub
extern
"C"
fn
__
rust_start_panic
()
{}
#[no_mangle]
pub
extern
fn
rust_eh_personality
()
{}
pub
extern
"C"
fn
rust_eh_personality
()
{}
src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs
浏览文件 @
4614671c
...
...
@@ -8,10 +8,10 @@
#![panic_runtime]
#[no_mangle]
pub
extern
fn
__
rust_maybe_catch_panic
()
{}
pub
extern
"C"
fn
__
rust_maybe_catch_panic
()
{}
#[no_mangle]
pub
extern
fn
__
rust_start_panic
()
{}
pub
extern
"C"
fn
__
rust_start_panic
()
{}
#[no_mangle]
pub
extern
fn
rust_eh_personality
()
{}
pub
extern
"C"
fn
rust_eh_personality
()
{}
src/test/ui/parser/bad-lit-suffixes.stderr
浏览文件 @
4614671c
...
...
@@ -110,16 +110,5 @@ LL | 1.0e10suffix;
|
= help: valid suffixes are `f32` and `f64`
error: extern declarations without an explicit ABI are deprecated
--> $DIR/bad-lit-suffixes.rs:5:1
|
LL | / extern
LL | | "C"suffix
LL | | {}
| |__^ ABI should be specified here
|
= note: `#[deny(missing_abi)]` on by default
= help: the default ABI is C
error: aborting due to 17 previous errors
error: aborting due to 16 previous errors
src/test/ui/proc-macro/signature.rs
浏览文件 @
4614671c
...
...
@@ -7,7 +7,7 @@
extern
crate
proc_macro
;
#[proc_macro_derive(A)]
pub
unsafe
extern
fn
foo
(
a
:
i32
,
b
:
u32
)
->
u32
{
pub
unsafe
extern
"C"
fn
foo
(
a
:
i32
,
b
:
u32
)
->
u32
{
//~^ ERROR: mismatched types
loop
{}
}
src/test/ui/proc-macro/signature.stderr
浏览文件 @
4614671c
error[E0308]: mismatched types
--> $DIR/signature.rs:10:1
|
LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
LL | / pub unsafe extern
"C"
fn foo(a: i32, b: u32) -> u32 {
LL | |
LL | | loop {}
LL | | }
...
...
src/test/ui/proc-macro/span-preservation.rs
浏览文件 @
4614671c
...
...
@@ -35,7 +35,7 @@ struct Bar {
}
#[recollect_attr]
extern
fn
bar
()
{
extern
"C"
fn
bar
()
{
0
//~ ERROR mismatched types
}
...
...
src/test/ui/proc-macro/span-preservation.stderr
浏览文件 @
4614671c
...
...
@@ -37,7 +37,7 @@ LL | let y = Foo { a: 10, b: 10isize };
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:39:5
|
LL | extern fn bar() {
LL | extern
"C"
fn bar() {
| - possibly return type missing here?
LL | 0
| ^ expected `()`, found integer
...
...
src/test/ui/range/issue-54505-no-std.rs
浏览文件 @
4614671c
...
...
@@ -13,7 +13,7 @@
#[cfg(any(not(target_arch
=
"wasm32"
),
target_os
=
"emscripten"
))]
#[lang
=
"eh_personality"
]
extern
fn
eh_personality
()
{}
extern
"C"
fn
eh_personality
()
{}
#[cfg(target_os
=
"emscripten"
)]
#[lang
=
"eh_catch_typeinfo"
]
static
EH_CATCH_TYPEINFO
:
u8
=
0
;
...
...
src/test/ui/signal-alternate-stack-cleanup.rs
浏览文件 @
4614671c
...
...
@@ -13,11 +13,11 @@
use
libc
::
*
;
unsafe
extern
fn
signal_handler
(
signum
:
c_int
,
_
:
*
mut
siginfo_t
,
_
:
*
mut
c_void
)
{
unsafe
extern
"C"
fn
signal_handler
(
signum
:
c_int
,
_
:
*
mut
siginfo_t
,
_
:
*
mut
c_void
)
{
assert_eq!
(
signum
,
SIGWINCH
);
}
extern
fn
send_signal
()
{
extern
"C"
fn
send_signal
()
{
unsafe
{
raise
(
SIGWINCH
);
}
...
...
src/test/ui/structs-enums/class-dtor.rs
浏览文件 @
4614671c
...
...
@@ -5,7 +5,7 @@
// pretty-expanded FIXME #23616
struct
cat
{
done
:
extern
fn
(
usize
),
done
:
extern
"C"
fn
(
usize
),
meows
:
usize
,
}
...
...
@@ -15,7 +15,7 @@ fn drop(&mut self) {
}
}
fn
cat
(
done
:
extern
fn
(
usize
))
->
cat
{
fn
cat
(
done
:
extern
"C"
fn
(
usize
))
->
cat
{
cat
{
meows
:
0
,
done
:
done
...
...
src/test/ui/symbol-names/impl1.rs
浏览文件 @
4614671c
...
...
@@ -60,7 +60,7 @@ fn method(&self) {}
}
// Test type mangling, by putting them in an `impl` header.
impl
Bar
for
[
&
'_
(
dyn
Foo
<
Assoc
=
extern
fn
(
&
u8
,
...
)
>
+
AutoTrait
);
3
]
{
impl
Bar
for
[
&
'_
(
dyn
Foo
<
Assoc
=
extern
"C"
fn
(
&
u8
,
...
)
>
+
AutoTrait
);
3
]
{
#[rustc_symbol_name]
//[legacy]~^ ERROR symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method
//[legacy]~| ERROR demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method
...
...
src/test/ui/type-param.rs
浏览文件 @
4614671c
...
...
@@ -6,6 +6,6 @@
// pretty-expanded FIXME #23616
type
lteq
<
T
>
=
extern
fn
(
T
)
->
bool
;
type
lteq
<
T
>
=
extern
"C"
fn
(
T
)
->
bool
;
pub
fn
main
()
{
}
src/test/ui/type-params-in-for-each.rs
浏览文件 @
4614671c
...
...
@@ -14,7 +14,7 @@ fn range_<F>(lo: usize, hi: usize, mut it: F) where F: FnMut(usize) {
while
lo_
<
hi
{
it
(
lo_
);
lo_
+=
1
;
}
}
fn
create_index
<
T
>
(
_
index
:
Vec
<
S
<
T
>>
,
_
hash_fn
:
extern
fn
(
T
)
->
usize
)
{
fn
create_index
<
T
>
(
_
index
:
Vec
<
S
<
T
>>
,
_
hash_fn
:
extern
"C"
fn
(
T
)
->
usize
)
{
range_
(
0
,
256
,
|
_
i
|
{
let
_
bucket
:
Vec
<
T
>
=
Vec
::
new
();
})
...
...
src/test/ui/unique/unique-ffi-symbols.rs
浏览文件 @
4614671c
...
...
@@ -3,12 +3,12 @@
// whenever the item path wasn't enough to disambiguate between them.
fn
main
()
{
let
a
=
{
extern
fn
good
()
->
i32
{
return
0
;
}
good
as
extern
fn
()
->
i32
extern
"C"
fn
good
()
->
i32
{
return
0
;
}
good
as
extern
"C"
fn
()
->
i32
};
let
b
=
{
extern
fn
good
()
->
i32
{
return
5
;
}
good
as
extern
fn
()
->
i32
extern
"C"
fn
good
()
->
i32
{
return
5
;
}
good
as
extern
"C"
fn
()
->
i32
};
assert
!
(
a
!=
b
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录