diff options
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/helpers/merge_imports.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/ide_db/src/helpers/merge_imports.rs b/crates/ide_db/src/helpers/merge_imports.rs index 697e8bcff..0dbabb44f 100644 --- a/crates/ide_db/src/helpers/merge_imports.rs +++ b/crates/ide_db/src/helpers/merge_imports.rs | |||
@@ -292,9 +292,7 @@ fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { | |||
292 | pub fn eq_visibility(vis0: Option<ast::Visibility>, vis1: Option<ast::Visibility>) -> bool { | 292 | pub fn eq_visibility(vis0: Option<ast::Visibility>, vis1: Option<ast::Visibility>) -> bool { |
293 | match (vis0, vis1) { | 293 | match (vis0, vis1) { |
294 | (None, None) => true, | 294 | (None, None) => true, |
295 | // FIXME: Don't use the string representation to check for equality | 295 | (Some(vis0), Some(vis1)) => vis0.is_eq_to(&vis1), |
296 | // spaces inside of the node would break this comparison | ||
297 | (Some(vis0), Some(vis1)) => vis0.to_string() == vis1.to_string(), | ||
298 | _ => false, | 296 | _ => false, |
299 | } | 297 | } |
300 | } | 298 | } |
@@ -303,9 +301,14 @@ pub fn eq_attrs( | |||
303 | attrs0: impl Iterator<Item = ast::Attr>, | 301 | attrs0: impl Iterator<Item = ast::Attr>, |
304 | attrs1: impl Iterator<Item = ast::Attr>, | 302 | attrs1: impl Iterator<Item = ast::Attr>, |
305 | ) -> bool { | 303 | ) -> bool { |
306 | let attrs0 = attrs0.map(|attr| attr.to_string()); | 304 | // FIXME order of attributes should not matter |
307 | let attrs1 = attrs1.map(|attr| attr.to_string()); | 305 | let attrs0 = attrs0 |
308 | attrs0.eq(attrs1) | 306 | .flat_map(|attr| attr.syntax().descendants_with_tokens()) |
307 | .flat_map(|it| it.into_token()); | ||
308 | let attrs1 = attrs1 | ||
309 | .flat_map(|attr| attr.syntax().descendants_with_tokens()) | ||
310 | .flat_map(|it| it.into_token()); | ||
311 | stdx::iter_eq_by(attrs0, attrs1, |tok, tok2| tok.text() == tok2.text()) | ||
309 | } | 312 | } |
310 | 313 | ||
311 | fn path_is_self(path: &ast::Path) -> bool { | 314 | fn path_is_self(path: &ast::Path) -> bool { |