diff options
Diffstat (limited to 'crates/ide/src')
-rw-r--r-- | crates/ide/src/inlay_hints.rs | 20 | ||||
-rw-r--r-- | crates/ide/src/references/rename.rs | 6 |
2 files changed, 22 insertions, 4 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 54485fd30..2f37c8040 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs | |||
@@ -416,8 +416,11 @@ fn get_string_representation(expr: &ast::Expr) -> Option<String> { | |||
416 | name_ref => Some(name_ref.to_owned()), | 416 | name_ref => Some(name_ref.to_owned()), |
417 | } | 417 | } |
418 | } | 418 | } |
419 | ast::Expr::FieldExpr(field_expr) => Some(field_expr.name_ref()?.to_string()), | ||
420 | ast::Expr::PathExpr(path_expr) => Some(path_expr.to_string()), | ||
421 | ast::Expr::PrefixExpr(prefix_expr) => get_string_representation(&prefix_expr.expr()?), | ||
419 | ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?), | 422 | ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?), |
420 | _ => Some(expr.to_string()), | 423 | _ => None, |
421 | } | 424 | } |
422 | } | 425 | } |
423 | 426 | ||
@@ -1438,4 +1441,19 @@ fn main() { | |||
1438 | "#, | 1441 | "#, |
1439 | ) | 1442 | ) |
1440 | } | 1443 | } |
1444 | |||
1445 | #[test] | ||
1446 | fn param_name_hints_show_for_literals() { | ||
1447 | check( | ||
1448 | r#"pub fn test(a: i32, b: i32) -> [i32; 2] { [a, b] } | ||
1449 | fn main() { | ||
1450 | test( | ||
1451 | 0x0fab272b, | ||
1452 | //^^^^^^^^^^ a | ||
1453 | 0x0fab272b | ||
1454 | //^^^^^^^^^^ b | ||
1455 | ); | ||
1456 | }"#, | ||
1457 | ) | ||
1458 | } | ||
1441 | } | 1459 | } |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index c25bcce50..99a558532 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -9,7 +9,7 @@ use ide_db::{ | |||
9 | search::FileReference, | 9 | search::FileReference, |
10 | RootDatabase, | 10 | RootDatabase, |
11 | }; | 11 | }; |
12 | use stdx::assert_never; | 12 | use stdx::never; |
13 | use syntax::{ | 13 | use syntax::{ |
14 | ast::{self, NameOwner}, | 14 | ast::{self, NameOwner}, |
15 | lex_single_syntax_kind, AstNode, SyntaxKind, SyntaxNode, T, | 15 | lex_single_syntax_kind, AstNode, SyntaxKind, SyntaxNode, T, |
@@ -285,7 +285,7 @@ fn rename_mod( | |||
285 | } | 285 | } |
286 | 286 | ||
287 | fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> { | 287 | fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> { |
288 | if assert_never!(local.is_self(sema.db)) { | 288 | if never!(local.is_self(sema.db)) { |
289 | bail!("rename_to_self invoked on self"); | 289 | bail!("rename_to_self invoked on self"); |
290 | } | 290 | } |
291 | 291 | ||
@@ -388,7 +388,7 @@ fn rename_self_to_param( | |||
388 | let (file_id, self_param) = match local.source(sema.db) { | 388 | let (file_id, self_param) = match local.source(sema.db) { |
389 | InFile { file_id, value: Either::Right(self_param) } => (file_id, self_param), | 389 | InFile { file_id, value: Either::Right(self_param) } => (file_id, self_param), |
390 | _ => { | 390 | _ => { |
391 | assert_never!(true, "rename_self_to_param invoked on a non-self local"); | 391 | never!(true, "rename_self_to_param invoked on a non-self local"); |
392 | bail!("rename_self_to_param invoked on a non-self local"); | 392 | bail!("rename_self_to_param invoked on a non-self local"); |
393 | } | 393 | } |
394 | }; | 394 | }; |