Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8a2bc53

Browse files
committedJun 16, 2025··
error on calls to ABIs that cannot be called
1 parent d9ca9bd commit 8a2bc53

14 files changed

+1364
-326
lines changed
 

‎compiler/rustc_abi/src/extern_abi.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,47 @@ impl ExternAbi {
249249
_ => false,
250250
}
251251
}
252+
253+
/// Can a function with this ABI be called with a rust call expression?
254+
///
255+
/// Some ABIs cannot be called from rust, either because rust does not know how to
256+
/// generate code for the call, or because a call does not semantically make sense.
257+
pub fn can_be_called_with_call_expr(self) -> bool {
258+
match self {
259+
// Rust doesn't know how to call functions with this ABI.
260+
ExternAbi::Custom => false,
261+
262+
// This is a function for the GPU, and cannot be called by the host.
263+
ExternAbi::PtxKernel | ExternAbi::GpuKernel => false,
264+
265+
// The interrupt ABIs should only be called by the CPU.
266+
// They have complex pre- and postconditions.
267+
ExternAbi::AvrInterrupt
268+
| ExternAbi::AvrNonBlockingInterrupt
269+
| ExternAbi::Msp430Interrupt
270+
| ExternAbi::RiscvInterruptM
271+
| ExternAbi::RiscvInterruptS
272+
| ExternAbi::X86Interrupt => false,
273+
274+
ExternAbi::C { .. }
275+
| ExternAbi::System { .. }
276+
| ExternAbi::Rust
277+
| ExternAbi::RustCall
278+
| ExternAbi::RustCold
279+
| ExternAbi::Unadjusted
280+
| ExternAbi::EfiApi
281+
| ExternAbi::Aapcs { .. }
282+
| ExternAbi::CCmseNonSecureCall
283+
| ExternAbi::CCmseNonSecureEntry
284+
| ExternAbi::Cdecl { .. }
285+
| ExternAbi::Stdcall { .. }
286+
| ExternAbi::Fastcall { .. }
287+
| ExternAbi::Thiscall { .. }
288+
| ExternAbi::Vectorcall { .. }
289+
| ExternAbi::SysV64 { .. }
290+
| ExternAbi::Win64 { .. } => true,
291+
}
292+
}
252293
}
253294

254295
pub fn all_names() -> Vec<&'static str> {

‎compiler/rustc_hir_typeck/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
hir_typeck_abi_custom_call =
2-
functions with the `"custom"` ABI cannot be called
3-
.note = an `extern "custom"` function can only be called from within inline assembly
1+
hir_typeck_abi_cannot_be_called =
2+
functions with the `"{$abi}"` ABI cannot be called
3+
.note = an `extern "{$abi}"` function can only be called using inline assembly
44
55
hir_typeck_add_missing_parentheses_in_range = you must surround the range in parentheses to call its `{$func_name}` function
66

‎compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::iter;
22

3-
use rustc_abi::ExternAbi;
43
use rustc_ast::util::parser::ExprPrecedence;
54
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey};
65
use rustc_hir::def::{self, CtorKind, Namespace, Res};
@@ -84,7 +83,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8483
while result.is_none() && autoderef.next().is_some() {
8584
result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef);
8685
}
87-
self.check_call_custom_abi(autoderef.final_ty(false), call_expr.span);
86+
self.check_call_abi(autoderef.final_ty(false), call_expr.span);
8887
self.register_predicates(autoderef.into_obligations());
8988

9089
let output = match result {
@@ -137,19 +136,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
137136
output
138137
}
139138

140-
/// Functions of type `extern "custom" fn(/* ... */)` cannot be called using `ExprKind::Call`.
141-
///
142-
/// These functions have a calling convention that is unknown to rust, hence it cannot generate
143-
/// code for the call. The only way to execute such a function is via inline assembly.
144-
fn check_call_custom_abi(&self, callee_ty: Ty<'tcx>, span: Span) {
139+
fn check_call_abi(&self, callee_ty: Ty<'tcx>, span: Span) {
145140
let abi = match callee_ty.kind() {
146141
ty::FnDef(def_id, _) => self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi,
147142
ty::FnPtr(_, header) => header.abi,
148143
_ => return,
149144
};
150145

151-
if let ExternAbi::Custom = abi {
152-
self.tcx.dcx().emit_err(errors::AbiCustomCall { span });
146+
// Some ABIs cannot be called from rust, either because rust does not know how to generate
147+
// code for the call, or because a call does not semantically make sense.
148+
if !abi.can_be_called_with_call_expr() {
149+
self.tcx.dcx().emit_err(crate::errors::AbiCannotBeCalled { span, abi: abi.as_str() });
153150
}
154151
}
155152

‎compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,10 @@ pub(crate) struct NakedFunctionsMustNakedAsm {
11651165
}
11661166

11671167
#[derive(Diagnostic)]
1168-
#[diag(hir_typeck_abi_custom_call)]
1169-
pub(crate) struct AbiCustomCall {
1168+
#[diag(hir_typeck_abi_cannot_be_called)]
1169+
pub(crate) struct AbiCannotBeCalled {
11701170
#[primary_span]
1171+
#[note]
11711172
pub span: Span,
1173+
pub abi: &'static str,
11721174
}

‎compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! See [`rustc_hir_analysis::check`] for more context on type checking in general.
77
8-
use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx};
8+
use rustc_abi::{FIRST_VARIANT, FieldIdx};
99
use rustc_ast::util::parser::ExprPrecedence;
1010
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1111
use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -1651,12 +1651,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16511651
Some(method.def_id),
16521652
);
16531653

1654-
// Functions of type `extern "custom" fn(/* ... */)` cannot be called using
1655-
// `ExprKind::MethodCall`. These functions have a calling convention that is
1656-
// unknown to rust, hence it cannot generate code for the call. The only way
1657-
// to execute such a function is via inline assembly.
1658-
if let ExternAbi::Custom = method.sig.abi {
1659-
self.tcx.dcx().emit_err(crate::errors::AbiCustomCall { span: expr.span });
1654+
// Some ABIs cannot be called from rust, either because rust does not know how to generate
1655+
// code for the call, or because a call does not semantically make sense.
1656+
if !method.sig.abi.can_be_called_with_call_expr() {
1657+
self.tcx.dcx().emit_err(crate::errors::AbiCannotBeCalled {
1658+
span: expr.span,
1659+
abi: method.sig.abi.as_str(),
1660+
});
16601661
}
16611662

16621663
method.sig.output()

‎tests/ui/abi/bad-custom.stderr

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,42 +248,84 @@ LL | extern "custom" fn negate(a: i64) -> i64 {
248248
error: functions with the `"custom"` ABI cannot be called
249249
--> $DIR/bad-custom.rs:75:14
250250
|
251+
LL | unsafe { f(x) }
252+
| ^^^^
253+
|
254+
note: an `extern "custom"` function can only be called using inline assembly
255+
--> $DIR/bad-custom.rs:75:14
256+
|
251257
LL | unsafe { f(x) }
252258
| ^^^^
253259

254260
error: functions with the `"custom"` ABI cannot be called
255261
--> $DIR/bad-custom.rs:80:14
256262
|
263+
LL | unsafe { f(x) }
264+
| ^^^^
265+
|
266+
note: an `extern "custom"` function can only be called using inline assembly
267+
--> $DIR/bad-custom.rs:80:14
268+
|
257269
LL | unsafe { f(x) }
258270
| ^^^^
259271

260272
error: functions with the `"custom"` ABI cannot be called
261273
--> $DIR/bad-custom.rs:87:14
262274
|
275+
LL | unsafe { f(x) }
276+
| ^^^^
277+
|
278+
note: an `extern "custom"` function can only be called using inline assembly
279+
--> $DIR/bad-custom.rs:87:14
280+
|
263281
LL | unsafe { f(x) }
264282
| ^^^^
265283

266284
error: functions with the `"custom"` ABI cannot be called
267285
--> $DIR/bad-custom.rs:109:20
268286
|
287+
LL | assert_eq!(double(21), 42);
288+
| ^^^^^^^^^^
289+
|
290+
note: an `extern "custom"` function can only be called using inline assembly
291+
--> $DIR/bad-custom.rs:109:20
292+
|
269293
LL | assert_eq!(double(21), 42);
270294
| ^^^^^^^^^^
271295

272296
error: functions with the `"custom"` ABI cannot be called
273297
--> $DIR/bad-custom.rs:112:29
274298
|
299+
LL | assert_eq!(unsafe { increment(41) }, 42);
300+
| ^^^^^^^^^^^^^
301+
|
302+
note: an `extern "custom"` function can only be called using inline assembly
303+
--> $DIR/bad-custom.rs:112:29
304+
|
275305
LL | assert_eq!(unsafe { increment(41) }, 42);
276306
| ^^^^^^^^^^^^^
277307

278308
error: functions with the `"custom"` ABI cannot be called
279309
--> $DIR/bad-custom.rs:115:17
280310
|
311+
LL | assert!(Thing(41).is_even());
312+
| ^^^^^^^^^^^^^^^^^^^
313+
|
314+
note: an `extern "custom"` function can only be called using inline assembly
315+
--> $DIR/bad-custom.rs:115:17
316+
|
281317
LL | assert!(Thing(41).is_even());
282318
| ^^^^^^^^^^^^^^^^^^^
283319

284320
error: functions with the `"custom"` ABI cannot be called
285321
--> $DIR/bad-custom.rs:118:20
286322
|
323+
LL | assert_eq!(Thing::bitwise_not(42), !42);
324+
| ^^^^^^^^^^^^^^^^^^^^^^
325+
|
326+
note: an `extern "custom"` function can only be called using inline assembly
327+
--> $DIR/bad-custom.rs:118:20
328+
|
287329
LL | assert_eq!(Thing::bitwise_not(42), !42);
288330
| ^^^^^^^^^^^^^^^^^^^^^^
289331

‎tests/ui/abi/unsupported.aarch64.stderr

Lines changed: 194 additions & 52 deletions
Large diffs are not rendered by default.

‎tests/ui/abi/unsupported.arm.stderr

Lines changed: 190 additions & 48 deletions
Large diffs are not rendered by default.

‎tests/ui/abi/unsupported.i686.stderr

Lines changed: 173 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,28 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
99
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
1010

1111
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
12-
--> $DIR/unsupported.rs:43:1
12+
--> $DIR/unsupported.rs:44:1
1313
|
1414
LL | extern "ptx-kernel" {}
1515
| ^^^^^^^^^^^^^^^^^^^^^^
1616

17+
warning: the calling convention "gpu-kernel" is not supported on this target
18+
--> $DIR/unsupported.rs:49:15
19+
|
20+
LL | fn gpu_ptr(f: extern "gpu-kernel" fn()) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^
22+
|
23+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
24+
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
25+
26+
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
27+
--> $DIR/unsupported.rs:55:1
28+
|
29+
LL | extern "gpu-kernel" {}
30+
| ^^^^^^^^^^^^^^^^^^^^^^
31+
1732
warning: the calling convention "aapcs" is not supported on this target
18-
--> $DIR/unsupported.rs:50:17
33+
--> $DIR/unsupported.rs:60:17
1934
|
2035
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
2136
| ^^^^^^^^^^^^^^^^^^^
@@ -24,13 +39,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
2439
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
2540

2641
error[E0570]: `"aapcs"` is not a supported ABI for the current target
27-
--> $DIR/unsupported.rs:55:1
42+
--> $DIR/unsupported.rs:65:1
2843
|
2944
LL | extern "aapcs" {}
3045
| ^^^^^^^^^^^^^^^^^
3146

3247
warning: the calling convention "msp430-interrupt" is not supported on this target
33-
--> $DIR/unsupported.rs:60:18
48+
--> $DIR/unsupported.rs:70:18
3449
|
3550
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
3651
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +54,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
3954
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
4055

4156
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
42-
--> $DIR/unsupported.rs:65:1
57+
--> $DIR/unsupported.rs:76:1
4358
|
4459
LL | extern "msp430-interrupt" {}
4560
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4661

4762
warning: the calling convention "avr-interrupt" is not supported on this target
48-
--> $DIR/unsupported.rs:70:15
63+
--> $DIR/unsupported.rs:81:15
4964
|
5065
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
5166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,28 +69,43 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
5469
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
5570

5671
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
57-
--> $DIR/unsupported.rs:75:1
72+
--> $DIR/unsupported.rs:87:1
5873
|
5974
LL | extern "avr-interrupt" {}
6075
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6176

6277
warning: the calling convention "riscv-interrupt-m" is not supported on this target
63-
--> $DIR/unsupported.rs:80:17
78+
--> $DIR/unsupported.rs:92:19
6479
|
65-
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
66-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) {
81+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6782
|
6883
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6984
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
7085

7186
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
72-
--> $DIR/unsupported.rs:85:1
87+
--> $DIR/unsupported.rs:98:1
7388
|
7489
LL | extern "riscv-interrupt-m" {}
7590
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7691

92+
warning: the calling convention "riscv-interrupt-s" is not supported on this target
93+
--> $DIR/unsupported.rs:103:19
94+
|
95+
LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) {
96+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97+
|
98+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
99+
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
100+
101+
error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target
102+
--> $DIR/unsupported.rs:109:1
103+
|
104+
LL | extern "riscv-interrupt-s" {}
105+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106+
77107
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
78-
--> $DIR/unsupported.rs:153:21
108+
--> $DIR/unsupported.rs:178:21
79109
|
80110
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
81111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -84,7 +114,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
84114
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
85115

86116
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
87-
--> $DIR/unsupported.rs:161:22
117+
--> $DIR/unsupported.rs:186:22
88118
|
89119
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
90120
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -93,7 +123,7 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
93123
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
94124

95125
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
96-
--> $DIR/unsupported.rs:166:1
126+
--> $DIR/unsupported.rs:191:1
97127
|
98128
LL | extern "C-cmse-nonsecure-entry" {}
99129
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -104,43 +134,133 @@ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
104134
LL | extern "ptx-kernel" fn ptx() {}
105135
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106136

137+
error: functions with the `"ptx-kernel"` ABI cannot be called
138+
--> $DIR/unsupported.rs:41:5
139+
|
140+
LL | f()
141+
| ^^^
142+
|
143+
note: an `extern "ptx-kernel"` function can only be called using inline assembly
144+
--> $DIR/unsupported.rs:41:5
145+
|
146+
LL | f()
147+
| ^^^
148+
107149
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
108-
--> $DIR/unsupported.rs:45:1
150+
--> $DIR/unsupported.rs:47:1
109151
|
110152
LL | extern "gpu-kernel" fn gpu() {}
111153
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112154

155+
error: functions with the `"gpu-kernel"` ABI cannot be called
156+
--> $DIR/unsupported.rs:52:5
157+
|
158+
LL | f()
159+
| ^^^
160+
|
161+
note: an `extern "gpu-kernel"` function can only be called using inline assembly
162+
--> $DIR/unsupported.rs:52:5
163+
|
164+
LL | f()
165+
| ^^^
166+
113167
error[E0570]: `"aapcs"` is not a supported ABI for the current target
114-
--> $DIR/unsupported.rs:48:1
168+
--> $DIR/unsupported.rs:58:1
115169
|
116170
LL | extern "aapcs" fn aapcs() {}
117171
| ^^^^^^^^^^^^^^^^^^^^^^^^^
118172

119173
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
120-
--> $DIR/unsupported.rs:58:1
174+
--> $DIR/unsupported.rs:68:1
121175
|
122176
LL | extern "msp430-interrupt" fn msp430() {}
123177
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124178

179+
error: functions with the `"msp430-interrupt"` ABI cannot be called
180+
--> $DIR/unsupported.rs:73:5
181+
|
182+
LL | f()
183+
| ^^^
184+
|
185+
note: an `extern "msp430-interrupt"` function can only be called using inline assembly
186+
--> $DIR/unsupported.rs:73:5
187+
|
188+
LL | f()
189+
| ^^^
190+
125191
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
126-
--> $DIR/unsupported.rs:68:1
192+
--> $DIR/unsupported.rs:79:1
127193
|
128194
LL | extern "avr-interrupt" fn avr() {}
129195
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130196

197+
error: functions with the `"avr-interrupt"` ABI cannot be called
198+
--> $DIR/unsupported.rs:84:5
199+
|
200+
LL | f()
201+
| ^^^
202+
|
203+
note: an `extern "avr-interrupt"` function can only be called using inline assembly
204+
--> $DIR/unsupported.rs:84:5
205+
|
206+
LL | f()
207+
| ^^^
208+
131209
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
132-
--> $DIR/unsupported.rs:78:1
210+
--> $DIR/unsupported.rs:90:1
133211
|
134-
LL | extern "riscv-interrupt-m" fn riscv() {}
135-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
212+
LL | extern "riscv-interrupt-m" fn riscv_m() {}
213+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
214+
215+
error: functions with the `"riscv-interrupt-m"` ABI cannot be called
216+
--> $DIR/unsupported.rs:95:5
217+
|
218+
LL | f()
219+
| ^^^
220+
|
221+
note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly
222+
--> $DIR/unsupported.rs:95:5
223+
|
224+
LL | f()
225+
| ^^^
226+
227+
error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target
228+
--> $DIR/unsupported.rs:101:1
229+
|
230+
LL | extern "riscv-interrupt-s" fn riscv_s() {}
231+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
232+
233+
error: functions with the `"riscv-interrupt-s"` ABI cannot be called
234+
--> $DIR/unsupported.rs:106:5
235+
|
236+
LL | f()
237+
| ^^^
238+
|
239+
note: an `extern "riscv-interrupt-s"` function can only be called using inline assembly
240+
--> $DIR/unsupported.rs:106:5
241+
|
242+
LL | f()
243+
| ^^^
244+
245+
error: functions with the `"x86-interrupt"` ABI cannot be called
246+
--> $DIR/unsupported.rs:117:5
247+
|
248+
LL | f()
249+
| ^^^
250+
|
251+
note: an `extern "x86-interrupt"` function can only be called using inline assembly
252+
--> $DIR/unsupported.rs:117:5
253+
|
254+
LL | f()
255+
| ^^^
136256

137257
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
138-
--> $DIR/unsupported.rs:159:1
258+
--> $DIR/unsupported.rs:184:1
139259
|
140260
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
141261
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142262

143-
error: aborting due to 13 previous errors; 7 warnings emitted
263+
error: aborting due to 23 previous errors; 9 warnings emitted
144264

145265
For more information about this error, try `rustc --explain E0570`.
146266
Future incompatibility report: Future breakage diagnostic:
@@ -154,9 +274,20 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
154274
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
155275
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
156276

277+
Future breakage diagnostic:
278+
warning: the calling convention "gpu-kernel" is not supported on this target
279+
--> $DIR/unsupported.rs:49:15
280+
|
281+
LL | fn gpu_ptr(f: extern "gpu-kernel" fn()) {
282+
| ^^^^^^^^^^^^^^^^^^^^^^^^
283+
|
284+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
285+
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
286+
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
287+
157288
Future breakage diagnostic:
158289
warning: the calling convention "aapcs" is not supported on this target
159-
--> $DIR/unsupported.rs:50:17
290+
--> $DIR/unsupported.rs:60:17
160291
|
161292
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
162293
| ^^^^^^^^^^^^^^^^^^^
@@ -167,7 +298,7 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
167298

168299
Future breakage diagnostic:
169300
warning: the calling convention "msp430-interrupt" is not supported on this target
170-
--> $DIR/unsupported.rs:60:18
301+
--> $DIR/unsupported.rs:70:18
171302
|
172303
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
173304
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -178,7 +309,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
178309

179310
Future breakage diagnostic:
180311
warning: the calling convention "avr-interrupt" is not supported on this target
181-
--> $DIR/unsupported.rs:70:15
312+
--> $DIR/unsupported.rs:81:15
182313
|
183314
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
184315
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -189,18 +320,29 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
189320

190321
Future breakage diagnostic:
191322
warning: the calling convention "riscv-interrupt-m" is not supported on this target
192-
--> $DIR/unsupported.rs:80:17
323+
--> $DIR/unsupported.rs:92:19
324+
|
325+
LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) {
326+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
327+
|
328+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
329+
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
330+
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
331+
332+
Future breakage diagnostic:
333+
warning: the calling convention "riscv-interrupt-s" is not supported on this target
334+
--> $DIR/unsupported.rs:103:19
193335
|
194-
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
195-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
336+
LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) {
337+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196338
|
197339
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
198340
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
199341
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
200342

201343
Future breakage diagnostic:
202344
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
203-
--> $DIR/unsupported.rs:153:21
345+
--> $DIR/unsupported.rs:178:21
204346
|
205347
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
206348
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -211,7 +353,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
211353

212354
Future breakage diagnostic:
213355
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
214-
--> $DIR/unsupported.rs:161:22
356+
--> $DIR/unsupported.rs:186:22
215357
|
216358
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
217359
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/abi/unsupported.riscv32.stderr

Lines changed: 152 additions & 42 deletions
Large diffs are not rendered by default.

‎tests/ui/abi/unsupported.riscv64.stderr

Lines changed: 152 additions & 42 deletions
Large diffs are not rendered by default.

‎tests/ui/abi/unsupported.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ fn ptx_ptr(f: extern "ptx-kernel" fn()) {
3939
//~^ WARN unsupported_fn_ptr_calling_conventions
4040
//~^^ WARN this was previously accepted
4141
f()
42+
//~^ ERROR functions with the `"ptx-kernel"` ABI cannot be called
4243
}
4344
extern "ptx-kernel" {}
4445
//~^ ERROR is not a supported ABI
46+
4547
extern "gpu-kernel" fn gpu() {}
4648
//~^ ERROR is not a supported ABI
49+
fn gpu_ptr(f: extern "gpu-kernel" fn()) {
50+
//~^ WARN unsupported_fn_ptr_calling_conventions
51+
//~^^ WARN this was previously accepted
52+
f()
53+
//~^ ERROR functions with the `"gpu-kernel"` ABI cannot be called
54+
}
55+
extern "gpu-kernel" {}
56+
//~^ ERROR is not a supported ABI
4757

4858
extern "aapcs" fn aapcs() {}
4959
//[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
@@ -61,6 +71,7 @@ fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
6171
//~^ WARN unsupported_fn_ptr_calling_conventions
6272
//~^^ WARN this was previously accepted
6373
f()
74+
//~^ ERROR functions with the `"msp430-interrupt"` ABI cannot be called
6475
}
6576
extern "msp430-interrupt" {}
6677
//~^ ERROR is not a supported ABI
@@ -71,26 +82,40 @@ fn avr_ptr(f: extern "avr-interrupt" fn()) {
7182
//~^ WARN unsupported_fn_ptr_calling_conventions
7283
//~^^ WARN this was previously accepted
7384
f()
85+
//~^ ERROR functions with the `"avr-interrupt"` ABI cannot be called
7486
}
7587
extern "avr-interrupt" {}
7688
//~^ ERROR is not a supported ABI
7789

78-
extern "riscv-interrupt-m" fn riscv() {}
90+
extern "riscv-interrupt-m" fn riscv_m() {}
7991
//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI
80-
fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
92+
fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) {
8193
//[x64,x64_win,i686,arm,aarch64]~^ WARN unsupported_fn_ptr_calling_conventions
8294
//[x64,x64_win,i686,arm,aarch64]~^^ WARN this was previously accepted
8395
f()
96+
//~^ ERROR functions with the `"riscv-interrupt-m"` ABI cannot be called
8497
}
8598
extern "riscv-interrupt-m" {}
8699
//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI
87100

101+
extern "riscv-interrupt-s" fn riscv_s() {}
102+
//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI
103+
fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) {
104+
//[x64,x64_win,i686,arm,aarch64]~^ WARN unsupported_fn_ptr_calling_conventions
105+
//[x64,x64_win,i686,arm,aarch64]~^^ WARN this was previously accepted
106+
f()
107+
//~^ ERROR functions with the `"riscv-interrupt-s"` ABI cannot be called
108+
}
109+
extern "riscv-interrupt-s" {}
110+
//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI
111+
88112
extern "x86-interrupt" fn x86() {}
89113
//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI
90114
fn x86_ptr(f: extern "x86-interrupt" fn()) {
91115
//[aarch64,arm,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions
92116
//[aarch64,arm,riscv32,riscv64]~^^ WARN this was previously accepted
93117
f()
118+
//~^ ERROR functions with the `"x86-interrupt"` ABI cannot be called
94119
}
95120
extern "x86-interrupt" {}
96121
//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI

‎tests/ui/abi/unsupported.x64.stderr

Lines changed: 186 additions & 44 deletions
Large diffs are not rendered by default.

‎tests/ui/abi/unsupported.x64_win.stderr

Lines changed: 186 additions & 44 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.