aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-27 13:20:58 +0000
committerLukas Wirth <[email protected]>2021-01-27 14:03:43 +0000
commit0aaa61cd5679112a0b2e5b5c53bc9edc41d6153c (patch)
tree36b854d8bfd70734fdca0386f1526b7b46e4c593 /crates
parent2f223d8c157c940b4e78918f65ac033f8291f7b1 (diff)
Only hide parameter hints for path, field and methodcall expressions
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/inlay_hints.rs20
1 files changed, 19 insertions, 1 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] }
1449fn main() {
1450 test(
1451 0x0fab272b,
1452 //^^^^^^^^^^ a
1453 0x0fab272b
1454 //^^^^^^^^^^ b
1455 );
1456}"#,
1457 )
1458 }
1441} 1459}