@@ -41,7 +41,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
4141 match hygiene. name_ref_to_name ( name_ref) {
4242 Either :: Left ( name) => {
4343 let args = segment
44- . type_arg_list ( )
44+ . generic_arg_list ( )
4545 . and_then ( |it| lower_generic_args ( & ctx, it) )
4646 . or_else ( || {
4747 lower_generic_args_from_fn_path (
@@ -148,33 +148,37 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
148148
149149pub ( super ) fn lower_generic_args (
150150 lower_ctx : & LowerCtx ,
151- node : ast:: TypeArgList ,
151+ node : ast:: GenericArgList ,
152152) -> Option < GenericArgs > {
153153 let mut args = Vec :: new ( ) ;
154- for type_arg in node. type_args ( ) {
155- let type_ref = TypeRef :: from_ast_opt ( lower_ctx, type_arg. ty ( ) ) ;
156- args. push ( GenericArg :: Type ( type_ref) ) ;
157- }
158- // lifetimes ignored for now
159154 let mut bindings = Vec :: new ( ) ;
160- for assoc_type_arg in node. assoc_type_args ( ) {
161- let assoc_type_arg: ast:: AssocTypeArg = assoc_type_arg;
162- if let Some ( name_ref) = assoc_type_arg. name_ref ( ) {
163- let name = name_ref. as_name ( ) ;
164- let type_ref = assoc_type_arg. ty ( ) . map ( |it| TypeRef :: from_ast ( lower_ctx, it) ) ;
165- let bounds = if let Some ( l) = assoc_type_arg. type_bound_list ( ) {
166- l. bounds ( ) . map ( |it| TypeBound :: from_ast ( lower_ctx, it) ) . collect ( )
167- } else {
168- Vec :: new ( )
169- } ;
170- bindings. push ( AssociatedTypeBinding { name, type_ref, bounds } ) ;
155+ for generic_arg in node. generic_args ( ) {
156+ match generic_arg {
157+ ast:: GenericArg :: TypeArg ( type_arg) => {
158+ let type_ref = TypeRef :: from_ast_opt ( lower_ctx, type_arg. ty ( ) ) ;
159+ args. push ( GenericArg :: Type ( type_ref) ) ;
160+ }
161+ ast:: GenericArg :: AssocTypeArg ( assoc_type_arg) => {
162+ if let Some ( name_ref) = assoc_type_arg. name_ref ( ) {
163+ let name = name_ref. as_name ( ) ;
164+ let type_ref = assoc_type_arg. ty ( ) . map ( |it| TypeRef :: from_ast ( lower_ctx, it) ) ;
165+ let bounds = if let Some ( l) = assoc_type_arg. type_bound_list ( ) {
166+ l. bounds ( ) . map ( |it| TypeBound :: from_ast ( lower_ctx, it) ) . collect ( )
167+ } else {
168+ Vec :: new ( )
169+ } ;
170+ bindings. push ( AssociatedTypeBinding { name, type_ref, bounds } ) ;
171+ }
172+ }
173+ // Lifetimes and constants are ignored for now.
174+ ast:: GenericArg :: LifetimeArg ( _) | ast:: GenericArg :: ConstArg ( _) => ( ) ,
171175 }
172176 }
177+
173178 if args. is_empty ( ) && bindings. is_empty ( ) {
174- None
175- } else {
176- Some ( GenericArgs { args, has_self_type : false , bindings } )
179+ return None ;
177180 }
181+ Some ( GenericArgs { args, has_self_type : false , bindings } )
178182}
179183
180184/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
0 commit comments