@@ -147,7 +147,9 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
147147 // ```
148148 // we should think what is the expected behavior here.
149149 // (we should probably just accept this by revealing opaques?)
150- if caller_sig. inputs_and_output != callee_sig. inputs_and_output {
150+ if caller_sig. inputs_and_output != callee_sig. inputs_and_output
151+ && !matches ! ( callee_sig. abi( ) , ExternAbi :: RustTail )
152+ {
151153 let caller_ty = self . tcx . type_of ( self . caller_def_id ) . skip_binder ( ) ;
152154
153155 self . report_signature_mismatch (
@@ -189,6 +191,12 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
189191 if callee_sig. c_variadic ( ) {
190192 self . report_c_variadic_callee ( expr. span ) ;
191193 }
194+
195+ for & arg_ty in callee_sig. inputs ( ) {
196+ if !arg_ty. is_sized ( self . tcx , self . typing_env ) {
197+ self . report_unsized_argument ( expr. span , arg_ty) ;
198+ }
199+ }
192200 }
193201
194202 /// Returns true if the caller function needs a location argument
@@ -417,6 +425,17 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
417425
418426 self . found_errors = Err ( err) ;
419427 }
428+
429+ fn report_unsized_argument ( & mut self , sp : Span , arg_ty : Ty < ' tcx > ) {
430+ let err = self
431+ . tcx
432+ . dcx ( )
433+ . struct_span_err ( sp, format ! ( "unsized arguments cannot be used in a tail call" ) )
434+ . with_note ( format ! ( "unsized argument of type `{arg_ty}`" ) )
435+ . emit ( ) ;
436+
437+ self . found_errors = Err ( err) ;
438+ }
420439}
421440
422441impl < ' a , ' tcx > Visitor < ' a , ' tcx > for TailCallCkVisitor < ' a , ' tcx > {
0 commit comments