From 35c948ff4a36b9c031bda96f79b8bf9e0d5bda26 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 25 May 2021 14:24:08 +0200 Subject: Fix lowering of FnOnce() without return type This should result in an implicit `-> ()`, not leaving out the binding. --- crates/hir_def/src/path/lower.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'crates/hir_def/src') diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs index 5d5dd9c8f..54ede7393 100644 --- a/crates/hir_def/src/path/lower.rs +++ b/crates/hir_def/src/path/lower.rs @@ -205,15 +205,14 @@ fn lower_generic_args_from_fn_path( ) -> Option { let mut args = Vec::new(); let mut bindings = Vec::new(); - if let Some(params) = params { - let mut param_types = Vec::new(); - for param in params.params() { - let type_ref = TypeRef::from_ast_opt(&ctx, param.ty()); - param_types.push(type_ref); - } - let arg = GenericArg::Type(TypeRef::Tuple(param_types)); - args.push(arg); + let params = params?; + let mut param_types = Vec::new(); + for param in params.params() { + let type_ref = TypeRef::from_ast_opt(&ctx, param.ty()); + param_types.push(type_ref); } + let arg = GenericArg::Type(TypeRef::Tuple(param_types)); + args.push(arg); if let Some(ret_type) = ret_type { let type_ref = TypeRef::from_ast_opt(&ctx, ret_type.ty()); bindings.push(AssociatedTypeBinding { @@ -221,10 +220,14 @@ fn lower_generic_args_from_fn_path( type_ref: Some(type_ref), bounds: Vec::new(), }); - } - if args.is_empty() && bindings.is_empty() { - None } else { - Some(GenericArgs { args, has_self_type: false, bindings }) + // -> () + let type_ref = TypeRef::Tuple(Vec::new()); + bindings.push(AssociatedTypeBinding { + name: name![Output], + type_ref: Some(type_ref), + bounds: Vec::new(), + }); } + Some(GenericArgs { args, has_self_type: false, bindings }) } -- cgit v1.2.3