diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-31 19:12:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 19:12:38 +0100 |
commit | 38ab326aac70484cb951fe9389d788d525d41550 (patch) | |
tree | 0032223efeefca76340fb0a97f6f12d0e432a2a9 /crates/ra_ide/src/inlay_hints.rs | |
parent | 5cade89d730b025082ff2df70aace259951a9ccf (diff) | |
parent | 98181087984157e27faba0b969e384f3c62c39d5 (diff) |
Merge #5631
5631: Finalize pattern grammar r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/inlay_hints.rs')
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 4bbbcd258..1bacead63 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -78,7 +78,7 @@ pub(crate) fn inlay_hints( | |||
78 | match node { | 78 | match node { |
79 | ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, | 79 | ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, |
80 | ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, | 80 | ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, |
81 | ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); }, | 81 | ast::IdentPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); }, |
82 | _ => (), | 82 | _ => (), |
83 | } | 83 | } |
84 | } | 84 | } |
@@ -161,7 +161,7 @@ fn get_param_name_hints( | |||
161 | Either::Left(self_param) => Some((self_param.to_string(), arg)), | 161 | Either::Left(self_param) => Some((self_param.to_string(), arg)), |
162 | Either::Right(pat) => { | 162 | Either::Right(pat) => { |
163 | let param_name = match pat { | 163 | let param_name = match pat { |
164 | ast::Pat::BindPat(it) => it.name()?.to_string(), | 164 | ast::Pat::IdentPat(it) => it.name()?.to_string(), |
165 | it => it.to_string(), | 165 | it => it.to_string(), |
166 | }; | 166 | }; |
167 | Some((param_name, arg)) | 167 | Some((param_name, arg)) |
@@ -182,7 +182,7 @@ fn get_bind_pat_hints( | |||
182 | acc: &mut Vec<InlayHint>, | 182 | acc: &mut Vec<InlayHint>, |
183 | sema: &Semantics<RootDatabase>, | 183 | sema: &Semantics<RootDatabase>, |
184 | config: &InlayHintsConfig, | 184 | config: &InlayHintsConfig, |
185 | pat: ast::BindPat, | 185 | pat: ast::IdentPat, |
186 | ) -> Option<()> { | 186 | ) -> Option<()> { |
187 | if !config.type_hints { | 187 | if !config.type_hints { |
188 | return None; | 188 | return None; |
@@ -202,7 +202,7 @@ fn get_bind_pat_hints( | |||
202 | Some(()) | 202 | Some(()) |
203 | } | 203 | } |
204 | 204 | ||
205 | fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type) -> bool { | 205 | fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &Type) -> bool { |
206 | if let Some(Adt::Enum(enum_data)) = pat_ty.as_adt() { | 206 | if let Some(Adt::Enum(enum_data)) = pat_ty.as_adt() { |
207 | let pat_text = bind_pat.to_string(); | 207 | let pat_text = bind_pat.to_string(); |
208 | enum_data | 208 | enum_data |
@@ -215,7 +215,11 @@ fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type | |||
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
218 | fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type) -> bool { | 218 | fn should_not_display_type_hint( |
219 | db: &RootDatabase, | ||
220 | bind_pat: &ast::IdentPat, | ||
221 | pat_ty: &Type, | ||
222 | ) -> bool { | ||
219 | if pat_ty.is_unknown() { | 223 | if pat_ty.is_unknown() { |
220 | return true; | 224 | return true; |
221 | } | 225 | } |