diff --git a/src/imports.rs b/src/imports.rs index 05b10519d45d..ec81d99b0f9d 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -35,7 +35,7 @@ pub fn path_to_imported_ident(path: &ast::Path) -> ast::Ident { impl<'a> FmtVisitor<'a> { pub fn format_import(&mut self, item: &ast::Item, tree: &ast::UseTree) { - let span = item.span; + let span = item.span(); let shape = self.shape(); let rw = UseTree::from_ast( &self.get_context(), diff --git a/src/visitor.rs b/src/visitor.rs index 05f2e7e5cc1b..71a279d93aad 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -303,6 +303,13 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { let filtered_attrs; let mut attrs = &item.attrs; match item.node { + // For use items, skip rewriting attributes. Just check for a skip attribute. + ast::ItemKind::Use(..) => { + if contains_skip(attrs) { + self.push_skipped_with_span(item.span()); + return; + } + } // Module is inline, in this case we treat it like any other item. _ if !is_mod_decl(item) => { if self.visit_attrs(&item.attrs, ast::AttrStyle::Outer) {