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

Commit caa13b3

Browse files
committed
Small changes in str formatting
1 parent 7c9e4e1 commit caa13b3

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

crates/syntax/src/ast/make.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use stdx::{format_to, never};
1414

1515
use crate::{ast, utils::is_raw_identifier, AstNode, SourceFile, SyntaxKind, SyntaxToken};
1616

17-
use super::WhereClause;
18-
1917
/// While the parent module defines basic atomic "constructors", the `ext`
2018
/// module defines shortcuts for common things.
2119
///
@@ -160,50 +158,47 @@ fn ty_from_text(text: &str) -> ast::Type {
160158
ast_from_text(&format!("type _T = {text};"))
161159
}
162160

163-
/** Related goto [link](https://doc.rust-lang.org/reference/items/type-aliases.html)
164-
Type Alias syntax is
165-
166-
```
167-
TypeAlias :
168-
type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? ( = Type WhereClause?)? ;
169-
```
170-
171-
FIXME : ident should be of type ast::Ident
172-
*/
161+
/// Related goto [link](https://doc.rust-lang.org/reference/items/type-aliases.html)
162+
/// Type Alias syntax is
163+
///
164+
/// ```
165+
/// TypeAlias :
166+
/// type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? ( = Type WhereClause?)? ;
167+
/// ```
168+
///
169+
/// FIXME : ident should be of type ast::Ident
173170
pub fn ty_alias(
174-
ident: String,
171+
ident: &str,
175172
generic_param_list: Option<ast::GenericParamList>,
176173
type_param_bounds: Option<ast::TypeParam>,
177-
where_clause: Option<WhereClause>,
174+
where_clause: Option<ast::WhereClause>,
178175
assignment: Option<(ast::Type, Option<ast::WhereClause>)>,
179176
) -> ast::TypeAlias {
180177
let mut s = String::new();
181-
s.push_str(format!("type {}", ident.as_str()).as_str());
178+
s.push_str(&format!("type {}", ident));
182179

183180
if let Some(list) = generic_param_list {
184-
s.push_str(list.to_string().as_str());
181+
s.push_str(&list.to_string());
185182
}
186183

187184
if let Some(list) = type_param_bounds {
188-
s.push_str(format!(" : {}", list.to_string().as_str()).as_str());
185+
s.push_str(&format!(" : {}", &list.to_string()));
189186
}
190187

191188
if let Some(cl) = where_clause {
192-
s.push_str(format!(" {}", cl.to_string().as_str()).as_str());
189+
s.push_str(&format!(" {}", &cl.to_string()));
193190
}
194191

195192
if let Some(exp) = assignment {
196193
if let Some(cl) = exp.1 {
197-
s.push_str(
198-
format!("= {} {}", exp.0.to_string().as_str(), cl.to_string().as_str()).as_str(),
199-
);
194+
s.push_str(&format!("= {} {}", &exp.0.to_string(), &cl.to_string()));
200195
} else {
201-
s.push_str(format!("= {}", exp.0.to_string().as_str()).as_str());
196+
s.push_str(&format!("= {}", &exp.0.to_string()));
202197
}
203198
}
204199

205200
s.push_str(";");
206-
ast_from_text(s.as_str())
201+
ast_from_text(&s)
207202
}
208203

209204
pub fn assoc_item_list() -> ast::AssocItemList {

0 commit comments

Comments
 (0)