@@ -14,8 +14,6 @@ use stdx::{format_to, never};
14
14
15
15
use crate :: { ast, utils:: is_raw_identifier, AstNode , SourceFile , SyntaxKind , SyntaxToken } ;
16
16
17
- use super :: WhereClause ;
18
-
19
17
/// While the parent module defines basic atomic "constructors", the `ext`
20
18
/// module defines shortcuts for common things.
21
19
///
@@ -160,50 +158,47 @@ fn ty_from_text(text: &str) -> ast::Type {
160
158
ast_from_text ( & format ! ( "type _T = {text};" ) )
161
159
}
162
160
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
173
170
pub fn ty_alias (
174
- ident : String ,
171
+ ident : & str ,
175
172
generic_param_list : Option < ast:: GenericParamList > ,
176
173
type_param_bounds : Option < ast:: TypeParam > ,
177
- where_clause : Option < WhereClause > ,
174
+ where_clause : Option < ast :: WhereClause > ,
178
175
assignment : Option < ( ast:: Type , Option < ast:: WhereClause > ) > ,
179
176
) -> ast:: TypeAlias {
180
177
let mut s = String :: new ( ) ;
181
- s. push_str ( format ! ( "type {}" , ident. as_str ( ) ) . as_str ( ) ) ;
178
+ s. push_str ( & format ! ( "type {}" , ident) ) ;
182
179
183
180
if let Some ( list) = generic_param_list {
184
- s. push_str ( list. to_string ( ) . as_str ( ) ) ;
181
+ s. push_str ( & list. to_string ( ) ) ;
185
182
}
186
183
187
184
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( ) ) ) ;
189
186
}
190
187
191
188
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( ) ) ) ;
193
190
}
194
191
195
192
if let Some ( exp) = assignment {
196
193
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( ) ) ) ;
200
195
} else {
201
- s. push_str ( format ! ( "= {}" , exp. 0 . to_string( ) . as_str ( ) ) . as_str ( ) ) ;
196
+ s. push_str ( & format ! ( "= {}" , & exp. 0 . to_string( ) ) ) ;
202
197
}
203
198
}
204
199
205
200
s. push_str ( ";" ) ;
206
- ast_from_text ( s . as_str ( ) )
201
+ ast_from_text ( & s )
207
202
}
208
203
209
204
pub fn assoc_item_list ( ) -> ast:: AssocItemList {
0 commit comments