@@ -43,7 +43,7 @@ use std::ptr;
43
43
use syntax_pos:: { self , Span , Pos } ;
44
44
use syntax:: ast;
45
45
use syntax:: symbol:: Symbol ;
46
- use rustc:: ty:: layout;
46
+ use rustc:: ty:: layout:: { self , LayoutTyper } ;
47
47
48
48
pub mod gdb;
49
49
mod utils;
@@ -320,8 +320,32 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
320
320
} ;
321
321
322
322
// Arguments types
323
- for & argument_type in inputs {
324
- signature. push ( type_metadata ( cx, argument_type, syntax_pos:: DUMMY_SP ) ) ;
323
+ if cx. sess ( ) . target . target . options . is_like_msvc {
324
+ // FIXME(#42800):
325
+ // There is a bug in MSDIA that leads to a crash when it encounters
326
+ // a fixed-size array of `u8` or something zero-sized in a
327
+ // function-type (see #40477).
328
+ // As a workaround, we replace those fixed-size arrays with a
329
+ // pointer-type. So a function `fn foo(a: u8, b: [u8; 4])` would
330
+ // appear as `fn foo(a: u8, b: *const u8)` in debuginfo,
331
+ // and a function `fn bar(x: [(); 7])` as `fn bar(x: *const ())`.
332
+ // This transformed type is wrong, but these function types are
333
+ // already inaccurate due to ABI adjustments (see #42800).
334
+ signature. extend ( inputs. iter ( ) . map ( |& t| {
335
+ let t = match t. sty {
336
+ ty:: TyArray ( ct, _)
337
+ if ( ct == cx. tcx ( ) . types . u8 ) ||
338
+ ( cx. layout_of ( ct) . size ( cx) . bytes ( ) == 0 ) => {
339
+ cx. tcx ( ) . mk_imm_ptr ( ct)
340
+ }
341
+ _ => t
342
+ } ;
343
+ type_metadata ( cx, t, syntax_pos:: DUMMY_SP )
344
+ } ) ) ;
345
+ } else {
346
+ signature. extend ( inputs. iter ( ) . map ( |t| {
347
+ type_metadata ( cx, t, syntax_pos:: DUMMY_SP )
348
+ } ) ) ;
325
349
}
326
350
327
351
if sig. abi == Abi :: RustCall && !sig. inputs ( ) . is_empty ( ) {
0 commit comments