From c9909f42ba4adf55b1e73e7118b48f1b10c80ac6 Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Fri, 12 Oct 2018 07:54:57 -0400 Subject: A FnDescriptor shouldn't exist without a name --- crates/ra_analysis/src/descriptors.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_analysis/src/descriptors.rs') diff --git a/crates/ra_analysis/src/descriptors.rs b/crates/ra_analysis/src/descriptors.rs index 4dcac1aa2..faf945a41 100644 --- a/crates/ra_analysis/src/descriptors.rs +++ b/crates/ra_analysis/src/descriptors.rs @@ -4,7 +4,7 @@ use std::{ use relative_path::RelativePathBuf; use ra_syntax::{ SmolStr, - ast::{self, NameOwner, AstNode, TypeParamsOwner}, + ast::{self, NameOwner, AstNode}, text_utils::is_subrange }; use { @@ -222,15 +222,15 @@ fn resolve_submodule( #[derive(Debug, Clone)] pub struct FnDescriptor { - pub name: Option, + pub name: String, pub label : String, pub ret_type: Option, pub params: Vec, } impl FnDescriptor { - pub fn new(node: ast::FnDef) -> Self { - let name = node.name().map(|name| name.text().to_string()); + pub fn new(node: ast::FnDef) -> Option { + let name = node.name()?.text().to_string(); // Strip the body out for the label. let label : String = if let Some(body) = node.body() { @@ -247,12 +247,12 @@ impl FnDescriptor { let params = FnDescriptor::param_list(node); let ret_type = node.ret_type().map(|r| r.syntax().text().to_string()); - FnDescriptor { + Some(FnDescriptor { name, ret_type, params, label - } + }) } fn param_list(node: ast::FnDef) -> Vec { -- cgit v1.2.3