Skip to content

Commit e59ceaf

Browse files
committed
Do not duplicate attributes on use items
1 parent f81b94c commit e59ceaf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn path_to_imported_ident(path: &ast::Path) -> ast::Ident {
3535

3636
impl<'a> FmtVisitor<'a> {
3737
pub fn format_import(&mut self, item: &ast::Item, tree: &ast::UseTree) {
38-
let span = item.span;
38+
let span = item.span();
3939
let shape = self.shape();
4040
let rw = UseTree::from_ast(
4141
&self.get_context(),

src/visitor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
303303
let filtered_attrs;
304304
let mut attrs = &item.attrs;
305305
match item.node {
306+
// For use items, skip rewriting attributes. Just check for a skip attribute.
307+
ast::ItemKind::Use(..) => {
308+
if contains_skip(attrs) {
309+
self.push_skipped_with_span(item.span());
310+
return;
311+
}
312+
}
306313
// Module is inline, in this case we treat it like any other item.
307314
_ if !is_mod_decl(item) => {
308315
if self.visit_attrs(&item.attrs, ast::AttrStyle::Outer) {

0 commit comments

Comments
 (0)