From a09d48380204fa948a3af397dc2188b93bf5793f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 14 Jul 2020 18:23:45 +0200 Subject: Thread varargs through r-a --- crates/ra_hir_def/src/type_ref.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_def/src/type_ref.rs') diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs index 86a77b704..e90b2a0b9 100644 --- a/crates/ra_hir_def/src/type_ref.rs +++ b/crates/ra_hir_def/src/type_ref.rs @@ -63,7 +63,7 @@ pub enum TypeRef { Array(Box /*, Expr*/), Slice(Box), /// A fn pointer. Last element of the vector is the return type. - Fn(Vec), + Fn(Vec, bool /*varargs*/), // For ImplTrait(Vec), DynTrait(Vec), @@ -118,7 +118,12 @@ impl TypeRef { .and_then(|rt| rt.type_ref()) .map(|it| TypeRef::from_ast(ctx, it)) .unwrap_or_else(|| TypeRef::Tuple(Vec::new())); + let mut is_varargs = false; let mut params = if let Some(pl) = inner.param_list() { + if let Some(param) = pl.params().last() { + is_varargs = param.dotdotdot_token().is_some(); + } + pl.params() .map(|p| p.ascribed_type()) .map(|it| TypeRef::from_ast_opt(&ctx, it)) @@ -127,7 +132,7 @@ impl TypeRef { Vec::new() }; params.push(ret_ty); - TypeRef::Fn(params) + TypeRef::Fn(params, is_varargs) } // for types are close enough for our purposes to the inner type for now... ast::TypeRef::ForType(inner) => TypeRef::from_ast_opt(&ctx, inner.type_ref()), @@ -158,7 +163,9 @@ impl TypeRef { fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) { f(type_ref); match type_ref { - TypeRef::Fn(types) | TypeRef::Tuple(types) => types.iter().for_each(|t| go(t, f)), + TypeRef::Fn(types, _) | TypeRef::Tuple(types) => { + types.iter().for_each(|t| go(t, f)) + } TypeRef::RawPtr(type_ref, _) | TypeRef::Reference(type_ref, _) | TypeRef::Array(type_ref) -- cgit v1.2.3