@@ -131,7 +131,8 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
131131 let callee_sig =
132132 self . tcx . normalize_erasing_late_bound_regions ( self . typing_env , ty. fn_sig ( self . tcx ) ) ;
133133
134- if caller_sig. abi ( ) != callee_sig. abi ( ) {
134+ if caller_sig. abi ( ) != callee_sig. abi ( ) && !matches ! ( callee_sig. abi( ) , ExternAbi :: RustTail )
135+ {
135136 self . report_abi_mismatch ( expr. span , caller_sig. abi ( ) , callee_sig. abi ( ) ) ;
136137 }
137138
@@ -147,7 +148,9 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
147148 // ```
148149 // we should think what is the expected behavior here.
149150 // (we should probably just accept this by revealing opaques?)
150- if caller_sig. inputs_and_output != callee_sig. inputs_and_output {
151+ if caller_sig. inputs_and_output != callee_sig. inputs_and_output
152+ && !matches ! ( callee_sig. abi( ) , ExternAbi :: RustTail )
153+ {
151154 let caller_ty = self . tcx . type_of ( self . caller_def_id ) . skip_binder ( ) ;
152155
153156 self . report_signature_mismatch (
@@ -189,6 +192,12 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
189192 if callee_sig. c_variadic ( ) {
190193 self . report_c_variadic_callee ( expr. span ) ;
191194 }
195+
196+ for & arg_ty in callee_sig. inputs ( ) {
197+ if !arg_ty. is_sized ( self . tcx , self . typing_env ) {
198+ self . report_unsized_argument ( expr. span , arg_ty) ;
199+ }
200+ }
192201 }
193202
194203 /// Returns true if the caller function needs a location argument
@@ -417,6 +426,17 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
417426
418427 self . found_errors = Err ( err) ;
419428 }
429+
430+ fn report_unsized_argument ( & mut self , sp : Span , arg_ty : Ty < ' tcx > ) {
431+ let err = self
432+ . tcx
433+ . dcx ( )
434+ . struct_span_err ( sp, format ! ( "unsized arguments cannot be used in a tail call" ) )
435+ . with_note ( format ! ( "unsized argument of type `{arg_ty}`" ) )
436+ . emit ( ) ;
437+
438+ self . found_errors = Err ( err) ;
439+ }
420440}
421441
422442impl < ' a , ' tcx > Visitor < ' a , ' tcx > for TailCallCkVisitor < ' a , ' tcx > {
0 commit comments