11use  rustc_abi:: { BackendRepr ,  Float ,  Integer ,  Primitive ,  RegKind } ; 
22use  rustc_attr_parsing:: InstructionSetAttr ; 
3- use  rustc_hir:: def_id:: DefId ; 
43use  rustc_middle:: mir:: mono:: { Linkage ,  MonoItem ,  MonoItemData ,  Visibility } ; 
54use  rustc_middle:: mir:: { Body ,  InlineAsmOperand } ; 
65use  rustc_middle:: ty:: layout:: { FnAbiOf ,  HasTyCtxt ,  HasTypingEnv ,  LayoutOf } ; 
76use  rustc_middle:: ty:: { Instance ,  Ty ,  TyCtxt } ; 
8- use  rustc_middle:: { bug,  span_bug ,   ty} ; 
7+ use  rustc_middle:: { bug,  ty} ; 
98use  rustc_span:: sym; 
109use  rustc_target:: callconv:: { ArgAbi ,  FnAbi ,  PassMode } ; 
11- use  rustc_target:: spec:: WasmCAbi ; 
1210
1311use  crate :: common; 
1412use  crate :: traits:: { AsmCodegenMethods ,  BuilderMethods ,  GlobalAsmOperandRef ,  MiscCodegenMethods } ; 
@@ -287,12 +285,7 @@ fn prefix_and_suffix<'tcx>(
287285                writeln ! ( begin,  "{}" ,  arch_prefix) . unwrap ( ) ; 
288286            } 
289287            writeln ! ( begin,  "{asm_name}:" ) . unwrap ( ) ; 
290-             writeln ! ( 
291-                 begin, 
292-                 ".functype {asm_name} {}" , 
293-                 wasm_functype( tcx,  fn_abi,  instance. def_id( ) ) 
294-             ) 
295-             . unwrap ( ) ; 
288+             writeln ! ( begin,  ".functype {asm_name} {}" ,  wasm_functype( tcx,  fn_abi) ) . unwrap ( ) ; 
296289
297290            writeln ! ( end) . unwrap ( ) ; 
298291            // .size is ignored for function symbols, so we can skip it 
@@ -306,7 +299,7 @@ fn prefix_and_suffix<'tcx>(
306299/// The webassembly type signature for the given function. 
307300/// 
308301/// Used by the `.functype` directive on wasm targets. 
309- fn  wasm_functype < ' tcx > ( tcx :  TyCtxt < ' tcx > ,  fn_abi :  & FnAbi < ' tcx ,  Ty < ' tcx > > ,   def_id :   DefId )  -> String  { 
302+ fn  wasm_functype < ' tcx > ( tcx :  TyCtxt < ' tcx > ,  fn_abi :  & FnAbi < ' tcx ,  Ty < ' tcx > > )  -> String  { 
310303    let  mut  signature = String :: with_capacity ( 64 ) ; 
311304
312305    let  ptr_type = match  tcx. data_layout . pointer_size . bits ( )  { 
@@ -315,17 +308,6 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
315308        other => bug ! ( "wasm pointer size cannot be {other} bits" ) , 
316309    } ; 
317310
318-     // FIXME: remove this once the wasm32-unknown-unknown ABI is fixed 
319-     // please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs` 
320-     // basically the commit introducing this comment should be reverted 
321-     if  let  PassMode :: Pair  {  .. }  = fn_abi. ret . mode  { 
322-         let  _ = WasmCAbi :: Legacy ; 
323-         span_bug ! ( 
324-             tcx. def_span( def_id) , 
325-             "cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666" 
326-         ) ; 
327-     } 
328- 
329311    let  hidden_return = matches ! ( fn_abi. ret. mode,  PassMode :: Indirect  {  .. } ) ; 
330312
331313    signature. push ( '(' ) ; 
@@ -339,7 +321,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
339321
340322    let  mut  it = fn_abi. args . iter ( ) . peekable ( ) ; 
341323    while  let  Some ( arg_abi)  = it. next ( )  { 
342-         wasm_type ( tcx ,   & mut  signature,  arg_abi,  ptr_type,  def_id ) ; 
324+         wasm_type ( & mut  signature,  arg_abi,  ptr_type) ; 
343325        if  it. peek ( ) . is_some ( )  { 
344326            signature. push_str ( ", " ) ; 
345327        } 
@@ -348,35 +330,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
348330    signature. push_str ( ") -> (" ) ; 
349331
350332    if  !hidden_return { 
351-         wasm_type ( tcx ,   & mut  signature,  & fn_abi. ret ,  ptr_type,  def_id ) ; 
333+         wasm_type ( & mut  signature,  & fn_abi. ret ,  ptr_type) ; 
352334    } 
353335
354336    signature. push ( ')' ) ; 
355337
356338    signature
357339} 
358340
359- fn  wasm_type < ' tcx > ( 
360-     tcx :  TyCtxt < ' tcx > , 
361-     signature :  & mut  String , 
362-     arg_abi :  & ArgAbi < ' _ ,  Ty < ' tcx > > , 
363-     ptr_type :  & ' static  str , 
364-     def_id :  DefId , 
365- )  { 
341+ fn  wasm_type < ' tcx > ( signature :  & mut  String ,  arg_abi :  & ArgAbi < ' _ ,  Ty < ' tcx > > ,  ptr_type :  & ' static  str )  { 
366342    match  arg_abi. mode  { 
367343        PassMode :: Ignore  => {  /* do nothing */  } 
368344        PassMode :: Direct ( _)  => { 
369345            let  direct_type = match  arg_abi. layout . backend_repr  { 
370346                BackendRepr :: Scalar ( scalar)  => wasm_primitive ( scalar. primitive ( ) ,  ptr_type) , 
371347                BackendRepr :: Vector  {  .. }  => "v128" , 
372-                 BackendRepr :: Memory  {  .. }  => { 
373-                     // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed 
374-                     let  _ = WasmCAbi :: Legacy ; 
375-                     span_bug ! ( 
376-                         tcx. def_span( def_id) , 
377-                         "cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666" 
378-                     ) ; 
379-                 } 
380348                other => unreachable ! ( "unexpected BackendRepr: {:?}" ,  other) , 
381349            } ; 
382350
0 commit comments