Merge pull request #2682 from topecongiro/issue-2670
Do not duplicate attributes on use items
This commit is contained in:
commit
bd7ae5e89b
@ -35,7 +35,7 @@ pub fn path_to_imported_ident(path: &ast::Path) -> ast::Ident {
|
|||||||
|
|
||||||
impl<'a> FmtVisitor<'a> {
|
impl<'a> FmtVisitor<'a> {
|
||||||
pub fn format_import(&mut self, item: &ast::Item, tree: &ast::UseTree) {
|
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 shape = self.shape();
|
||||||
let rw = UseTree::from_ast(
|
let rw = UseTree::from_ast(
|
||||||
&self.get_context(),
|
&self.get_context(),
|
||||||
|
@ -303,6 +303,13 @@ pub fn visit_item(&mut self, item: &ast::Item) {
|
|||||||
let filtered_attrs;
|
let filtered_attrs;
|
||||||
let mut attrs = &item.attrs;
|
let mut attrs = &item.attrs;
|
||||||
match item.node {
|
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.
|
// Module is inline, in this case we treat it like any other item.
|
||||||
_ if !is_mod_decl(item) => {
|
_ if !is_mod_decl(item) => {
|
||||||
if self.visit_attrs(&item.attrs, ast::AttrStyle::Outer) {
|
if self.visit_attrs(&item.attrs, ast::AttrStyle::Outer) {
|
||||||
|
@ -93,3 +93,7 @@ fn test() {
|
|||||||
/// This line is not affected.
|
/// This line is not affected.
|
||||||
// This line is deleted.
|
// This line is deleted.
|
||||||
use c;
|
use c;
|
||||||
|
|
||||||
|
// #2670
|
||||||
|
#[macro_use]
|
||||||
|
use imports_with_attr;
|
||||||
|
@ -105,3 +105,7 @@ fn test() {
|
|||||||
/// This line is not affected.
|
/// This line is not affected.
|
||||||
// This line is deleted.
|
// This line is deleted.
|
||||||
use c;
|
use c;
|
||||||
|
|
||||||
|
// #2670
|
||||||
|
#[macro_use]
|
||||||
|
use imports_with_attr;
|
||||||
|
Loading…
Reference in New Issue
Block a user