File tree Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1565,7 +1565,8 @@ pub(crate) fn recover_comment_removed(
15651565 context : & RewriteContext < ' _ > ,
15661566) -> Option < String > {
15671567 let snippet = context. snippet ( span) ;
1568- if snippet != new && changed_comment_content ( snippet, & new) {
1568+ let includes_comment = contains_comment ( snippet) ;
1569+ if snippet != new && includes_comment && changed_comment_content ( snippet, & new) {
15691570 // We missed some comments. Warn and keep the original text.
15701571 if context. config . error_on_unformatted ( ) {
15711572 context. report . append (
Original file line number Diff line number Diff line change @@ -107,5 +107,7 @@ fn format_stmt(
107107 }
108108 ast:: StmtKind :: Mac ( ..) | ast:: StmtKind :: Item ( ..) => None ,
109109 } ;
110- result. and_then ( |res| recover_comment_removed ( res, stmt. span ( ) , context) )
110+ result. and_then ( |res| {
111+ recover_comment_removed ( res, stmt. span ( ) , context)
112+ } )
111113}
Original file line number Diff line number Diff line change 1+ // rustfmt-normalize_doc_attributes: true
2+
3+ #[ doc = " item" ]
4+ fn main ( ) {
5+ #[ doc = " stmt" ]
6+ let _=( ) ;
7+ }
Original file line number Diff line number Diff line change 1+ // rustfmt-normalize_doc_attributes: true
2+
3+ /// item
4+ fn main ( ) {
5+ /// stmt
6+ let _ = ( ) ;
7+ }
You can’t perform that action at this time.
0 commit comments