@@ -1589,26 +1589,70 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15891589                // e.g. `reuse HasSelf::method;` should suggest `reuse HasSelf::method($args);`. 
15901590                full_call_span. shrink_to_hi ( ) 
15911591            } ; 
1592+ 
1593+             // Controls how the arguments should be listed in the suggestion. 
1594+             enum  ArgumentsFormatting  { 
1595+                 SingleLine , 
1596+                 Multiline  {  fallback_indent :  String ,  brace_indent :  String  } , 
1597+             } 
1598+             let  arguments_formatting = { 
1599+                 let  mut  provided_inputs = matched_inputs. iter ( ) . filter_map ( |a| * a) ; 
1600+                 if  let  Some ( brace_indent)  = source_map. indentation_before ( suggestion_span) 
1601+                     && let  Some ( first_idx)  = provided_inputs. by_ref ( ) . next ( ) 
1602+                     && let  Some ( last_idx)  = provided_inputs. by_ref ( ) . next ( ) 
1603+                     && let  ( _,  first_span)  = provided_arg_tys[ first_idx] 
1604+                     && let  ( _,  last_span)  = provided_arg_tys[ last_idx] 
1605+                     && source_map. is_multiline ( first_span. to ( last_span) ) 
1606+                     && let  Some ( fallback_indent)  = source_map. indentation_before ( first_span) 
1607+                 { 
1608+                     ArgumentsFormatting :: Multiline  {  fallback_indent,  brace_indent } 
1609+                 }  else  { 
1610+                     ArgumentsFormatting :: SingleLine 
1611+                 } 
1612+             } ; 
1613+ 
15921614            let  mut  suggestion = "(" . to_owned ( ) ; 
15931615            let  mut  needs_comma = false ; 
15941616            for  ( expected_idx,  provided_idx)  in  matched_inputs. iter_enumerated ( )  { 
1595-                 if  needs_comma { 
1596-                     suggestion += ", " ; 
1597-                 }  else  { 
1598-                     needs_comma = true ; 
1617+                 match  ( needs_comma,  & arguments_formatting)  { 
1618+                     ( true ,  ArgumentsFormatting :: SingleLine )  => { 
1619+                         suggestion += ", " ; 
1620+                     } 
1621+                     ( false ,  ArgumentsFormatting :: SingleLine )  => { 
1622+                         needs_comma = true ; 
1623+                     } 
1624+                     ( true ,  ArgumentsFormatting :: Multiline  {  .. } )  => { 
1625+                         suggestion += ",\n " ; 
1626+                     } 
1627+                     ( false ,  ArgumentsFormatting :: Multiline  {  .. } )  => { 
1628+                         suggestion += "\n " ; 
1629+                         needs_comma = true ; 
1630+                     } 
15991631                } 
1600-                 let  suggestion_text = if  let  Some ( provided_idx)  = provided_idx
1632+                 let  ( suggestion_span ,   suggestion_text)  = if  let  Some ( provided_idx)  = provided_idx
16011633                    && let  ( _,  provided_span)  = provided_arg_tys[ * provided_idx] 
16021634                    && let  Ok ( arg_text)  = source_map. span_to_snippet ( provided_span) 
16031635                { 
1604-                     arg_text
1636+                     ( Some ( provided_span ) ,   arg_text) 
16051637                }  else  { 
16061638                    // Propose a placeholder of the correct type 
16071639                    let  ( _,  expected_ty)  = formal_and_expected_inputs[ expected_idx] ; 
1608-                     ty_to_snippet ( expected_ty,  expected_idx) 
1640+                     ( None ,   ty_to_snippet ( expected_ty,  expected_idx) ) 
16091641                } ; 
1642+                 if  let  ArgumentsFormatting :: Multiline  {  fallback_indent,  .. }  =
1643+                     & arguments_formatting
1644+                 { 
1645+                     let  indent = suggestion_span
1646+                         . and_then ( |span| source_map. indentation_before ( span) ) 
1647+                         . unwrap_or_else ( || fallback_indent. clone ( ) ) ; 
1648+                     suggestion += & indent; 
1649+                 } 
16101650                suggestion += & suggestion_text; 
16111651            } 
1652+             if  let  ArgumentsFormatting :: Multiline  {  brace_indent,  .. }  = arguments_formatting { 
1653+                 suggestion += "\n " ; 
1654+                 suggestion += & brace_indent; 
1655+             } 
16121656            suggestion += ")" ; 
16131657            err. span_suggestion_verbose ( 
16141658                suggestion_span, 
0 commit comments