From db0b791b247b0ad8f013446429f83273636709c9 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 29 Apr 2024 16:19:52 -0500 Subject: [PATCH] cl-ast: Fix pretty-printing for use items --- compiler/cl-ast/src/ast_impl.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/compiler/cl-ast/src/ast_impl.rs b/compiler/cl-ast/src/ast_impl.rs index 1c47709..c442bb5 100644 --- a/compiler/cl-ast/src/ast_impl.rs +++ b/compiler/cl-ast/src/ast_impl.rs @@ -284,11 +284,8 @@ mod display { impl Display for Use { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let Self { absolute, tree } = self; - if *absolute { - write!(f, "use ::{tree}") - } else { - write!(f, "use {tree}") - } + f.write_str(if *absolute { "use ::" } else { "use " })?; + write!(f, "{tree};") } } @@ -790,13 +787,13 @@ mod path { } /// Concatenates `self::other`. If `other` is an absolute [Path], /// this replaces `self` with `other` - pub fn concat(&mut self, other: &Self) -> &mut Self { + pub fn concat(mut self, other: &Self) -> Self { if other.absolute { - *self = other.clone(); + other.clone() } else { - self.parts.extend(other.parts.iter().cloned()) + self.parts.extend(other.parts.iter().cloned()); + self } - self } } impl PathPart {