Skip to content

Commit

Permalink
Treat super and crate as top_level in use merge.
Browse files Browse the repository at this point in the history
commit-id:1c46a8b9
  • Loading branch information
gilbens-starkware committed Dec 22, 2024
1 parent 63dc720 commit f973093
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/cairo-lang-formatter/src/formatter_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ impl UseTree {

let mut nested_paths = vec![];
for (segment, subtree) in self.children {
let (subtree_merged_use_items, is_single_leaf) =
subtree.create_merged_use_items(allow_duplicate_uses, false);
let (subtree_merged_use_items, is_single_leaf) = subtree.create_merged_use_items(
allow_duplicate_uses,
matches!(segment.as_str(), "crate" | "super"),
);

let formatted_subtree_paths =
subtree_merged_use_items.into_iter().map(|child| format!("{segment}::{child}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ use d::{e, *};
// Testing not merging the top level.
use x;
use y;
// Testing not merging crate and super.
use crate::a;
use crate::b;
use crate::c::d;
use crate::c::e;
use super::a;
use super::b;
use super::c::d;
use super::c::e;
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ use a::{c, d};
// Testing wildcard.
mod w;
use a::{*, a, b, c};
// Testing not merging crate and super.
use crate::a;
use crate::b;
use crate::c::{d, e};
use d::{*, e};
use super::a;
use super::b;
use super::c::{d, e};
// Testing not merging the top level.
use x;
use y;

0 comments on commit f973093

Please sign in to comment.