@@ -20,7 +20,8 @@ use crate::expr::{
2020 ExprType , RhsTactics ,
2121} ;
2222use crate :: lists:: {
23- definitive_tactic, itemize_list, write_list, ListFormatting , ListItem , Separator ,
23+ definitive_tactic, extract_pre_comment, itemize_list, write_list, ListFormatting , ListItem ,
24+ Separator ,
2425} ;
2526use crate :: macros:: { rewrite_macro, MacroPosition } ;
2627use crate :: overflow;
@@ -2291,9 +2292,15 @@ fn rewrite_args(
22912292 // Account for sugary self.
22922293 // FIXME: the comment for the self argument is dropped. This is blocked
22932294 // on rust issue #27522.
2295+ let mut comment_str = "" ;
22942296 let min_args = explicit_self
22952297 . and_then ( |explicit_self| rewrite_explicit_self ( explicit_self, args, context) )
22962298 . map_or ( 1 , |self_str| {
2299+ let comment_span = mk_sp ( span. lo ( ) , args[ 0 ] . pat . span . lo ( ) ) ;
2300+ comment_str = context
2301+ . snippet_provider
2302+ . span_to_snippet ( comment_span)
2303+ . unwrap ( ) ;
22972304 arg_item_strs[ 0 ] = self_str;
22982305 2
22992306 } ) ;
@@ -2368,7 +2375,12 @@ fn rewrite_args(
23682375 && ( arg_items. is_empty ( )
23692376 || arg_items. len ( ) == 1 && arg_item_strs[ 0 ] . len ( ) <= one_line_budget) ;
23702377
2371- for ( item, arg) in arg_items. iter_mut ( ) . zip ( arg_item_strs) {
2378+ for ( index, ( item, arg) ) in arg_items. iter_mut ( ) . zip ( arg_item_strs) . enumerate ( ) {
2379+ if index == 0 && explicit_self. is_some ( ) {
2380+ let ( pre_comment, pre_comment_style) = extract_pre_comment ( comment_str) ;
2381+ item. pre_comment = pre_comment;
2382+ item. pre_comment_style = pre_comment_style;
2383+ }
23722384 item. item = Some ( arg) ;
23732385 }
23742386
0 commit comments