aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-20 22:23:50 +0000
committerGitHub <[email protected]>2021-03-20 22:23:50 +0000
commitbe3dc673e2f00eaa7cfbf4727cc69032ed0b6179 (patch)
treed5566d0f3cc77835aab5770fa9f08b0c0d48f1b1 /crates/ide_db
parent104a19853e0d5560a21e6c6a31961ca592be1032 (diff)
parent38048c35d800230d3e5a79041186366dd0ef44ae (diff)
Merge #8125
8125: Don't use an untyped String for ActiveParam tracking r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/call_info.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs
index 7e26c3ccf..e583a52f4 100644
--- a/crates/ide_db/src/call_info.rs
+++ b/crates/ide_db/src/call_info.rs
@@ -4,7 +4,7 @@ use either::Either;
4use hir::{HasAttrs, HirDisplay, Semantics, Type}; 4use hir::{HasAttrs, HirDisplay, Semantics, Type};
5use stdx::format_to; 5use stdx::format_to;
6use syntax::{ 6use syntax::{
7 ast::{self, ArgListOwner}, 7 ast::{self, ArgListOwner, NameOwner},
8 match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize, 8 match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize,
9}; 9};
10 10
@@ -142,7 +142,7 @@ fn call_info_impl(
142#[derive(Debug)] 142#[derive(Debug)]
143pub struct ActiveParameter { 143pub struct ActiveParameter {
144 pub ty: Type, 144 pub ty: Type,
145 pub name: String, 145 pub pat: Either<ast::SelfParam, ast::Pat>,
146} 146}
147 147
148impl ActiveParameter { 148impl ActiveParameter {
@@ -165,8 +165,14 @@ impl ActiveParameter {
165 return None; 165 return None;
166 } 166 }
167 let (pat, ty) = params.swap_remove(idx); 167 let (pat, ty) = params.swap_remove(idx);
168 let name = pat?.to_string(); 168 pat.map(|pat| ActiveParameter { ty, pat })
169 Some(ActiveParameter { ty, name }) 169 }
170
171 pub fn ident(&self) -> Option<ast::Name> {
172 self.pat.as_ref().right().and_then(|param| match param {
173 ast::Pat::IdentPat(ident) => ident.name(),
174 _ => None,
175 })
170 } 176 }
171} 177}
172 178