@@ -153,22 +153,26 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
153153 } ;
154154 let Some ( asm_ty) = asm_ty else {
155155 let msg = format ! ( "cannot use value of type `{ty}` for inline assembly" ) ;
156- let mut err = self . tcx . dcx ( ) . struct_span_err ( expr. span , msg) ;
157- err. note (
158- "only integers, floats, SIMD vectors, pointers and function pointers \
159- can be used as arguments for inline assembly",
160- ) ;
161- err. emit ( ) ;
156+ self . tcx
157+ . dcx ( )
158+ . struct_span_err ( expr. span , msg)
159+ . note_mv (
160+ "only integers, floats, SIMD vectors, pointers and function pointers \
161+ can be used as arguments for inline assembly",
162+ )
163+ . emit ( ) ;
162164 return None ;
163165 } ;
164166
165167 // Check that the type implements Copy. The only case where this can
166168 // possibly fail is for SIMD types which don't #[derive(Copy)].
167169 if !ty. is_copy_modulo_regions ( self . tcx , self . param_env ) {
168170 let msg = "arguments for inline assembly must be copyable" ;
169- let mut err = self . tcx . dcx ( ) . struct_span_err ( expr. span , msg) ;
170- err. note ( format ! ( "`{ty}` does not implement the Copy trait" ) ) ;
171- err. emit ( ) ;
171+ self . tcx
172+ . dcx ( )
173+ . struct_span_err ( expr. span , msg)
174+ . note_mv ( format ! ( "`{ty}` does not implement the Copy trait" ) )
175+ . emit ( ) ;
172176 }
173177
174178 // Ideally we wouldn't need to do this, but LLVM's register allocator
@@ -183,16 +187,17 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
183187 if let Some ( ( in_expr, Some ( in_asm_ty) ) ) = tied_input {
184188 if in_asm_ty != asm_ty {
185189 let msg = "incompatible types for asm inout argument" ;
186- let mut err = self . tcx . dcx ( ) . struct_span_err ( vec ! [ in_expr. span, expr. span] , msg) ;
187-
188190 let in_expr_ty = ( self . get_operand_ty ) ( in_expr) ;
189- err. span_label ( in_expr. span , format ! ( "type `{in_expr_ty}`" ) ) ;
190- err. span_label ( expr. span , format ! ( "type `{ty}`" ) ) ;
191- err. note (
192- "asm inout arguments must have the same type, \
191+ self . tcx
192+ . dcx ( )
193+ . struct_span_err ( vec ! [ in_expr. span, expr. span] , msg)
194+ . span_label_mv ( in_expr. span , format ! ( "type `{in_expr_ty}`" ) )
195+ . span_label_mv ( expr. span , format ! ( "type `{ty}`" ) )
196+ . note_mv (
197+ "asm inout arguments must have the same type, \
193198 unless they are both pointers or integers of the same size",
194- ) ;
195- err . emit ( ) ;
199+ )
200+ . emit ( ) ;
196201 }
197202
198203 // All of the later checks have already been done on the input, so
@@ -234,13 +239,15 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
234239 if let Some ( feature) = feature {
235240 if !target_features. contains ( feature) {
236241 let msg = format ! ( "`{feature}` target feature is not enabled" ) ;
237- let mut err = self . tcx . dcx ( ) . struct_span_err ( expr. span , msg) ;
238- err. note ( format ! (
239- "this is required to use type `{}` with register class `{}`" ,
240- ty,
241- reg_class. name( ) ,
242- ) ) ;
243- err. emit ( ) ;
242+ self . tcx
243+ . dcx ( )
244+ . struct_span_err ( expr. span , msg)
245+ . note_mv ( format ! (
246+ "this is required to use type `{}` with register class `{}`" ,
247+ ty,
248+ reg_class. name( ) ,
249+ ) )
250+ . emit ( ) ;
244251 return Some ( asm_ty) ;
245252 }
246253 }
@@ -449,14 +456,17 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
449456 ty:: Never | ty:: Error ( _) => { }
450457 ty:: FnDef ( ..) => { }
451458 _ => {
452- let mut err =
453- self . tcx . dcx ( ) . struct_span_err ( * op_sp, "invalid `sym` operand" ) ;
454- err. span_label (
455- self . tcx . def_span ( anon_const. def_id ) ,
456- format ! ( "is {} `{}`" , ty. kind( ) . article( ) , ty) ,
457- ) ;
458- err. help ( "`sym` operands must refer to either a function or a static" ) ;
459- err. emit ( ) ;
459+ self . tcx
460+ . dcx ( )
461+ . struct_span_err ( * op_sp, "invalid `sym` operand" )
462+ . span_label_mv (
463+ self . tcx . def_span ( anon_const. def_id ) ,
464+ format ! ( "is {} `{}`" , ty. kind( ) . article( ) , ty) ,
465+ )
466+ . help_mv (
467+ "`sym` operands must refer to either a function or a static" ,
468+ )
469+ . emit ( ) ;
460470 }
461471 } ;
462472 }
0 commit comments