ast::{
self,
edit::{AstNodeEdit, IndentLevel},
- make, AstNode, PathSegmentKind, VisibilityOwner,
+ make, AstNode, AttrsOwner, PathSegmentKind, VisibilityOwner,
},
AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken,
};
}
}
+fn eq_attrs(
+ attrs0: impl Iterator<Item = ast::Attr>,
+ attrs1: impl Iterator<Item = ast::Attr>,
+) -> bool {
+ let attrs0 = attrs0.map(|attr| attr.to_string());
+ let attrs1 = attrs1.map(|attr| attr.to_string());
+ attrs0.eq(attrs1)
+}
+
pub fn try_merge_imports(
lhs: &ast::Use,
rhs: &ast::Use,
if !eq_visibility(lhs.visibility(), rhs.visibility()) {
return None;
}
+ if !eq_attrs(lhs.attrs(), rhs.attrs()) {
+ return None;
+ }
+
let lhs_tree = lhs.use_tree()?;
let rhs_tree = rhs.use_tree()?;
let merged = try_merge_trees(&lhs_tree, &rhs_tree, merge_behavior)?;
)
}
+#[test]
+fn merge_groups_skip_attributed() {
+ check_full(
+ "std::io",
+ r#"
+#[cfg(feature = "gated")] use std::fmt::{Result, Display};
+"#,
+ r#"
+#[cfg(feature = "gated")] use std::fmt::{Result, Display};
+use std::io;
+"#,
+ )
+}
+
#[test]
#[ignore] // FIXME: Support this
fn split_out_merge() {