Skip to content

Commit

Permalink
Rename Terminal to SelfReference
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Oct 23, 2024
1 parent a74554f commit 7e6736e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tooling/nargo_fmt/src/formatter/use_tree_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ enum Segment {
/// we need to know that "foo" is the end of a path, and "foo::bar" is another one.
/// If we don't, merging "foo" and "foo::bar" will result in just "foo::bar", loosing "foo",
/// when we actually want "foo::{self, bar}".
Terminal,
SelfReference,
Crate,
Super,
Dep,
Expand All @@ -115,7 +115,7 @@ enum Segment {
impl Segment {
/// Combines two segments into a single one, by joining them with "::".
fn combine(self, other: Segment) -> Segment {
if other == Segment::Terminal {
if other == Segment::SelfReference {
self
} else {
Segment::Plain(format!("{}::{}", self, other))
Expand All @@ -124,7 +124,7 @@ impl Segment {

fn order_number(&self) -> usize {
match self {
Segment::Terminal => 0,
Segment::SelfReference => 0,
Segment::Crate => 1,
Segment::Super => 2,
Segment::Dep => 3,
Expand All @@ -140,7 +140,7 @@ impl Display for Segment {
Segment::Super => write!(f, "super"),
Segment::Dep => write!(f, "dep"),
Segment::Plain(s) => write!(f, "{}", s),
Segment::Terminal => write!(f, "self"),
Segment::SelfReference => write!(f, "self"),
}
}
}
Expand Down Expand Up @@ -258,12 +258,12 @@ fn merge_imports_in_tree(imports: Vec<UseTree>, mut tree: &mut ImportTree) {
UseTreeKind::Path(ident, alias) => {
if let Some(alias) = alias {
tree = tree.insert(Segment::Plain(format!("{} as {}", ident, alias)));
tree.insert(Segment::Terminal);
tree.insert(Segment::SelfReference);
} else if ident.0.contents == "self" {
tree.insert(Segment::Terminal);
tree.insert(Segment::SelfReference);
} else {
tree = tree.insert(Segment::Plain(ident.to_string()));
tree.insert(Segment::Terminal);
tree.insert(Segment::SelfReference);
}
}
UseTreeKind::List(trees) => {
Expand Down

0 comments on commit 7e6736e

Please sign in to comment.