Do not duplicate attributes on use items

This commit is contained in:
topecongiro 2018-05-06 17:01:14 +09:00
parent f81b94c7c1
commit e59ceaf954
2 changed files with 8 additions and 1 deletions

@ -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(),

@ -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) {