@@ -27,6 +27,7 @@ enum NonAsmTypeReason<'tcx> {
27
27
UnevaluatedSIMDArrayLength ( DefId , ty:: Const < ' tcx > ) ,
28
28
Invalid ( Ty < ' tcx > ) ,
29
29
InvalidElement ( DefId , Ty < ' tcx > ) ,
30
+ NotSizedPtr ( Ty < ' tcx > ) ,
30
31
}
31
32
32
33
impl < ' a , ' tcx > InlineAsmCtxt < ' a , ' tcx > {
@@ -81,7 +82,13 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
81
82
ty:: Float ( FloatTy :: F64 ) => Ok ( InlineAsmType :: F64 ) ,
82
83
ty:: Float ( FloatTy :: F128 ) => Ok ( InlineAsmType :: F128 ) ,
83
84
ty:: FnPtr ( ..) => Ok ( asm_ty_isize) ,
84
- ty:: RawPtr ( ty, _) if self . is_thin_ptr_ty ( ty) => Ok ( asm_ty_isize) ,
85
+ ty:: RawPtr ( elem_ty, _) => {
86
+ if self . is_thin_ptr_ty ( elem_ty) {
87
+ Ok ( asm_ty_isize)
88
+ } else {
89
+ Err ( NonAsmTypeReason :: NotSizedPtr ( ty) )
90
+ }
91
+ }
85
92
ty:: Adt ( adt, args) if adt. repr ( ) . simd ( ) => {
86
93
let fields = & adt. non_enum_variant ( ) . fields ;
87
94
let field = & fields[ FieldIdx :: ZERO ] ;
@@ -187,6 +194,16 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
187
194
can be used as arguments for inline assembly",
188
195
) . emit ( ) ;
189
196
}
197
+ NonAsmTypeReason :: NotSizedPtr ( ty) => {
198
+ let msg = format ! (
199
+ "cannot use value of unsized pointer type `{ty}` for inline assembly"
200
+ ) ;
201
+ self . tcx
202
+ . dcx ( )
203
+ . struct_span_err ( expr. span , msg)
204
+ . with_note ( "only sized pointers can be used in inline assembly" )
205
+ . emit ( ) ;
206
+ }
190
207
NonAsmTypeReason :: InvalidElement ( did, ty) => {
191
208
let msg = format ! (
192
209
"cannot use SIMD vector with element type `{ty}` for inline assembly"
0 commit comments