@@ -89,10 +89,10 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
89
89
self . report_op ( ty, args, fn_span, expr) ;
90
90
}
91
91
92
- // Closures in thir look something akin to
93
- // `for<'a> extern "rust-call" fn(&'a [closure@...], ()) -> <[closure@...] as FnOnce<()>>::Output {<[closure@...] as Fn<()>>::call}`
94
- // So we have to check for them in this weird way...
95
92
if let & ty:: FnDef ( did, args) = ty. kind ( ) {
93
+ // Closures in thir look something akin to
94
+ // `for<'a> extern "rust-call" fn(&'a [closure@...], ()) -> <[closure@...] as FnOnce<()>>::Output {<[closure@...] as Fn<()>>::call}`
95
+ // So we have to check for them in this weird way...
96
96
let parent = self . tcx . parent ( did) ;
97
97
if self . tcx . fn_trait_kind_from_def_id ( parent) . is_some ( )
98
98
&& args. first ( ) . and_then ( |arg| arg. as_type ( ) ) . is_some_and ( Ty :: is_closure)
@@ -103,6 +103,10 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
103
103
// skip them, producing an error about calling a closure is enough.
104
104
return ;
105
105
} ;
106
+
107
+ if self . tcx . intrinsic ( did) . is_some ( ) {
108
+ self . report_calling_intrinsic ( expr) ;
109
+ }
106
110
}
107
111
108
112
// Erase regions since tail calls don't care about lifetimes
@@ -280,6 +284,16 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
280
284
self . found_errors = Err ( err) ;
281
285
}
282
286
287
+ fn report_calling_intrinsic ( & mut self , expr : & Expr < ' _ > ) {
288
+ let err = self
289
+ . tcx
290
+ . dcx ( )
291
+ . struct_span_err ( expr. span , "tail calling intrinsics is not allowed" )
292
+ . emit ( ) ;
293
+
294
+ self . found_errors = Err ( err) ;
295
+ }
296
+
283
297
fn report_abi_mismatch ( & mut self , sp : Span , caller_abi : ExternAbi , callee_abi : ExternAbi ) {
284
298
let err = self
285
299
. tcx
0 commit comments