]> git.lizzy.rs Git - rust.git/blobdiff - src/visitor.rs
Backport: Do not touch module with #![rustfmt::skip] (4297)
[rust.git] / src / visitor.rs
index e4a7be742abcbace1602fad9b5b45593b2dd71ad..ba446200232b563d0745b2e4c5a87f630a587b30 100644 (file)
@@ -948,12 +948,13 @@ fn format_mod(
 
     pub(crate) fn format_separate_mod(&mut self, m: &Module<'_>, end_pos: BytePos) {
         self.block_indent = Indent::empty();
-        if self.visit_attrs(m.attrs(), ast::AttrStyle::Inner) {
-            self.push_skipped_with_span(m.attrs(), m.span, m.span);
-        } else {
-            self.walk_mod_items(&m.items);
-            self.format_missing_with_indent(end_pos);
-        }
+        let skipped = self.visit_attrs(m.attrs(), ast::AttrStyle::Inner);
+        assert!(
+            !skipped,
+            "Skipping module must be handled before reaching this line."
+        );
+        self.walk_mod_items(&m.items);
+        self.format_missing_with_indent(end_pos);
     }
 
     pub(crate) fn skip_empty_lines(&mut self, end_pos: BytePos) {