@@ -1960,14 +1960,17 @@ impl Rewrite for ast::Param {
1960
1960
let param_attrs_result = self
1961
1961
. attrs
1962
1962
. rewrite ( context, Shape :: legacy ( shape. width , shape. indent ) ) ?;
1963
- let ( span, has_multiple_attr_lines) = if !self . attrs . is_empty ( ) {
1963
+ // N.B. Doc comments aren't typically valid syntax, but could appear
1964
+ // in the presence of certain macros - https://github.com/rust-lang/rustfmt/issues/4936
1965
+ let ( span, has_multiple_attr_lines, has_doc_comments) = if !self . attrs . is_empty ( ) {
1964
1966
let num_attrs = self . attrs . len ( ) ;
1965
1967
(
1966
1968
mk_sp ( self . attrs [ num_attrs - 1 ] . span . hi ( ) , self . pat . span . lo ( ) ) ,
1967
1969
param_attrs_result. contains ( '\n' ) ,
1970
+ self . attrs . iter ( ) . any ( |a| a. is_doc_comment ( ) ) ,
1968
1971
)
1969
1972
} else {
1970
- ( mk_sp ( self . span . lo ( ) , self . span . lo ( ) ) , false )
1973
+ ( mk_sp ( self . span . lo ( ) , self . span . lo ( ) ) , false , false )
1971
1974
} ;
1972
1975
1973
1976
if let Some ( ref explicit_self) = self . to_self ( ) {
@@ -1989,7 +1992,7 @@ impl Rewrite for ast::Param {
1989
1992
param_name,
1990
1993
span,
1991
1994
shape,
1992
- !has_multiple_attr_lines,
1995
+ !has_multiple_attr_lines && !has_doc_comments ,
1993
1996
) ?;
1994
1997
1995
1998
if !is_empty_infer ( & * self . ty , self . pat . span ) {
0 commit comments