Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit dba3fc4

Browse files
committed
style: remove unnecessary macro
1 parent 84e1314 commit dba3fc4

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

crates/ide-db/src/imports/merge_imports.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,14 @@ pub fn try_normalize_use_tree(
256256
Some(use_tree)
257257
}
258258

259-
macro_rules! call_and_track_result {
260-
($call:expr, $tracker: ident) => {
261-
let result = $call;
262-
if !$tracker && result.is_some() {
263-
$tracker = true;
264-
}
265-
};
266-
}
267-
268259
pub fn try_normalize_use_tree_mut(
269260
use_tree: &ast::UseTree,
270261
style: NormalizationStyle,
271262
) -> Option<()> {
272263
if style == NormalizationStyle::One {
273264
let mut modified = false;
274-
call_and_track_result!(use_tree.wrap_in_tree_list(), modified);
275-
call_and_track_result!(recursive_normalize(use_tree, style), modified);
265+
modified |= use_tree.wrap_in_tree_list().is_some();
266+
modified |= recursive_normalize(use_tree, style).is_some();
276267
if !modified {
277268
// Either the use tree was already normalized or its semantically empty.
278269
return None;
@@ -374,10 +365,9 @@ fn recursive_normalize(use_tree: &ast::UseTree, style: NormalizationStyle) -> Op
374365
if let Some(sub_one_tree_list) = one_style_tree_list(&sub_sub_tree) {
375366
curr_skipped.extend(sub_one_tree_list.use_trees());
376367
} else {
377-
call_and_track_result!(
378-
recursive_normalize(&sub_sub_tree, NormalizationStyle::Default),
379-
modified
380-
);
368+
modified |=
369+
recursive_normalize(&sub_sub_tree, NormalizationStyle::Default)
370+
.is_some();
381371
add_element_to_list(
382372
sub_sub_tree.syntax().clone().into(),
383373
&mut elements,
@@ -401,10 +391,7 @@ fn recursive_normalize(use_tree: &ast::UseTree, style: NormalizationStyle) -> Op
401391
}
402392
modified = true;
403393
} else {
404-
call_and_track_result!(
405-
recursive_normalize(&subtree, NormalizationStyle::Default),
406-
modified
407-
);
394+
modified |= recursive_normalize(&subtree, NormalizationStyle::Default).is_some();
408395
}
409396
}
410397

@@ -451,7 +438,7 @@ fn recursive_normalize(use_tree: &ast::UseTree, style: NormalizationStyle) -> Op
451438
// Merge the remaining subtree into its parent, if its only one and
452439
// the normalization style is not "one".
453440
if subtrees.len() == 1 && style != NormalizationStyle::One {
454-
call_and_track_result!(merge_subtree_into_parent_tree(&subtrees[0]), modified);
441+
modified |= merge_subtree_into_parent_tree(&subtrees[0]).is_some();
455442
}
456443
// Order the remaining subtrees (if necessary).
457444
if subtrees.len() > 1 {

0 commit comments

Comments
 (0)