File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 2
2
3
3
use std:: time:: { Duration , Instant } ;
4
4
5
- use rustc_ast:: ast;
5
+ use rustc_ast:: { ast, attr :: HasAttrs } ;
6
6
use rustc_span:: symbol;
7
7
8
8
pub ( crate ) use syntux:: session:: ParseSess ;
@@ -14,7 +14,7 @@ use crate::formatting::{
14
14
newline_style:: apply_newline_style,
15
15
report:: NonFormattedRange ,
16
16
syntux:: parser:: { DirectoryOwnership , Parser , ParserError } ,
17
- utils:: count_newlines,
17
+ utils:: { contains_skip , count_newlines} ,
18
18
visitor:: FmtVisitor ,
19
19
} ;
20
20
use crate :: {
@@ -129,6 +129,10 @@ fn format_project(
129
129
if ( !operation_setting. recursive && path != & main_file) || should_ignore {
130
130
continue ;
131
131
}
132
+ if contains_skip ( module. attrs ( ) ) {
133
+ continue ;
134
+ }
135
+
132
136
should_emit_verbose ( input_is_stdin, operation_setting. verbosity , || {
133
137
println ! ( "Formatting {}" , path)
134
138
} ) ;
Original file line number Diff line number Diff line change @@ -959,12 +959,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
959
959
960
960
pub ( crate ) fn format_separate_mod ( & mut self , m : & Module < ' _ > , end_pos : BytePos ) {
961
961
self . block_indent = Indent :: empty ( ) ;
962
- if self . visit_attrs ( m. attrs ( ) , ast:: AttrStyle :: Inner ) {
963
- self . push_skipped_with_span ( m. attrs ( ) , m. as_ref ( ) . inner , m. as_ref ( ) . inner ) ;
964
- } else {
965
- self . walk_mod_items ( m. as_ref ( ) ) ;
966
- self . format_missing_with_indent ( end_pos) ;
967
- }
962
+ let skipped = self . visit_attrs ( m. attrs ( ) , ast:: AttrStyle :: Inner ) ;
963
+ assert ! (
964
+ !skipped,
965
+ "Skipping module must be handled before reaching this line." ,
966
+ ) ;
967
+
968
+ self . walk_mod_items ( m. as_ref ( ) ) ;
969
+ self . format_missing_with_indent ( end_pos) ;
968
970
}
969
971
970
972
pub ( crate ) fn skip_empty_lines ( & mut self , end_pos : BytePos ) {
You can’t perform that action at this time.
0 commit comments