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(
1565
1565
context : & RewriteContext < ' _ > ,
1566
1566
) -> Option < String > {
1567
1567
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) {
1569
1570
// We missed some comments. Warn and keep the original text.
1570
1571
if context. config . error_on_unformatted ( ) {
1571
1572
context. report . append (
Original file line number Diff line number Diff line change @@ -107,5 +107,7 @@ fn format_stmt(
107
107
}
108
108
ast:: StmtKind :: Mac ( ..) | ast:: StmtKind :: Item ( ..) => None ,
109
109
} ;
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
+ } )
111
113
}
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