@@ -88,6 +88,9 @@ pub mod ext {
88
88
block_expr ( None , None )
89
89
}
90
90
91
+ pub fn ty_name ( name : ast:: Name ) -> ast:: Type {
92
+ ty_path ( ident_path ( & format ! ( "{name}" ) ) )
93
+ }
91
94
pub fn ty_bool ( ) -> ast:: Type {
92
95
ty_path ( ident_path ( "bool" ) )
93
96
}
@@ -160,6 +163,7 @@ pub fn assoc_item_list() -> ast::AssocItemList {
160
163
ast_from_text ( "impl C for D {}" )
161
164
}
162
165
166
+ // FIXME: `ty_params` should be `ast::GenericArgList`
163
167
pub fn impl_ (
164
168
ty : ast:: Path ,
165
169
params : Option < ast:: GenericParamList > ,
@@ -185,10 +189,6 @@ pub fn impl_trait(
185
189
ast_from_text ( & format ! ( "impl{ty_params} {trait_} for {ty}{ty_params} {{}}" ) )
186
190
}
187
191
188
- pub ( crate ) fn generic_arg_list ( ) -> ast:: GenericArgList {
189
- ast_from_text ( "const S: T<> = ();" )
190
- }
191
-
192
192
pub fn path_segment ( name_ref : ast:: NameRef ) -> ast:: PathSegment {
193
193
ast_from_text ( & format ! ( "type __ = {name_ref};" ) )
194
194
}
@@ -718,6 +718,21 @@ pub fn generic_param_list(
718
718
ast_from_text ( & format ! ( "fn f<{args}>() {{ }}" ) )
719
719
}
720
720
721
+ pub fn type_arg ( ty : ast:: Type ) -> ast:: TypeArg {
722
+ ast_from_text ( & format ! ( "const S: T<{ty}> = ();" ) )
723
+ }
724
+
725
+ pub fn lifetime_arg ( lifetime : ast:: Lifetime ) -> ast:: LifetimeArg {
726
+ ast_from_text ( & format ! ( "const S: T<{lifetime}> = ();" ) )
727
+ }
728
+
729
+ pub ( crate ) fn generic_arg_list (
730
+ args : impl IntoIterator < Item = ast:: GenericArg > ,
731
+ ) -> ast:: GenericArgList {
732
+ let args = args. into_iter ( ) . join ( ", " ) ;
733
+ ast_from_text ( & format ! ( "const S: T<{args}> = ();" ) )
734
+ }
735
+
721
736
pub fn visibility_pub_crate ( ) -> ast:: Visibility {
722
737
ast_from_text ( "pub(crate) struct S" )
723
738
}
0 commit comments