File tree 4 files changed +52
-11
lines changed
compiler/rustc_hir_analysis/src
4 files changed +52
-11
lines changed Original file line number Diff line number Diff line change @@ -409,6 +409,11 @@ fn check_constraints<'tcx>(
409
409
emit("recursive delegation is not supported yet");
410
410
}
411
411
412
+ if tcx.fn_sig(sig_id).skip_binder().skip_binder().c_variadic {
413
+ // See issue #127443 for explanation.
414
+ emit("delegation to C-variadic functions is not allowed");
415
+ }
416
+
412
417
ret
413
418
}
414
419
Original file line number Diff line number Diff line change
1
+ //@ aux-crate:fn_header_aux=fn-header-aux.rs
2
+
3
+ #![feature(c_variadic)]
4
+ #![feature(fn_delegation)]
5
+ #![allow(incomplete_features)]
6
+
7
+ mod to_reuse {
8
+ pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {}
9
+ }
10
+
11
+ reuse to_reuse::variadic_fn;
12
+ //~^ ERROR delegation to C-variadic functions is not allowed
13
+ reuse fn_header_aux::variadic_fn_extern;
14
+ //~^ ERROR delegation to C-variadic functions is not allowed
15
+
16
+ fn main() {
17
+ unsafe {
18
+ variadic_fn(0);
19
+ variadic_fn(0, 1);
20
+ variadic_fn_extern(0);
21
+ variadic_fn_extern(0, 1);
22
+ }
23
+ let _: unsafe extern "C" fn(usize, ...) = variadic_fn;
24
+ let _: unsafe extern "C" fn(usize, ...) = variadic_fn_extern;
25
+ }
Original file line number Diff line number Diff line change
1
+ error: delegation to C-variadic functions is not allowed
2
+ --> $DIR/fn-header-variadic.rs:11:17
3
+ |
4
+ LL | pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {}
5
+ | ------------------------------------------------------------- callee defined here
6
+ ...
7
+ LL | reuse to_reuse::variadic_fn;
8
+ | ^^^^^^^^^^^
9
+
10
+ error: delegation to C-variadic functions is not allowed
11
+ --> $DIR/fn-header-variadic.rs:13:22
12
+ |
13
+ LL | reuse fn_header_aux::variadic_fn_extern;
14
+ | ^^^^^^^^^^^^^^^^^^
15
+ |
16
+ ::: $DIR/auxiliary/fn-header-aux.rs:7:1
17
+ |
18
+ LL | pub unsafe extern "C" fn variadic_fn_extern(n: usize, mut args: ...) {}
19
+ | -------------------------------------------------------------------- callee defined here
20
+
21
+ error: aborting due to 2 previous errors
22
+
Original file line number Diff line number Diff line change 10
10
mod to_reuse {
11
11
pub unsafe fn unsafe_fn() {}
12
12
pub extern "C" fn extern_fn() {}
13
- pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {}
14
13
pub const fn const_fn() {}
15
14
pub async fn async_fn() {}
16
15
}
17
16
18
17
reuse to_reuse::unsafe_fn;
19
18
reuse to_reuse::extern_fn;
20
- reuse to_reuse::variadic_fn;
21
19
reuse to_reuse::const_fn;
22
20
reuse to_reuse::async_fn;
23
21
24
22
reuse fn_header_aux::unsafe_fn_extern;
25
23
reuse fn_header_aux::extern_fn_extern;
26
- reuse fn_header_aux::variadic_fn_extern;
27
24
reuse fn_header_aux::const_fn_extern;
28
25
reuse fn_header_aux::async_fn_extern;
29
26
@@ -46,12 +43,4 @@ fn main() {
46
43
extern_fn_extern();
47
44
let _: extern "C" fn() = extern_fn;
48
45
let _: extern "C" fn() = extern_fn_extern;
49
- unsafe {
50
- variadic_fn(0);
51
- variadic_fn(0, 1);
52
- variadic_fn_extern(0);
53
- variadic_fn_extern(0, 1);
54
- }
55
- let _: unsafe extern "C" fn(usize, ...) = variadic_fn;
56
- let _: unsafe extern "C" fn(usize, ...) = variadic_fn_extern;
57
46
}
You can’t perform that action at this time.
0 commit comments