aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/inlay_hints.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-27 14:40:57 +0000
committerGitHub <[email protected]>2021-01-27 14:40:57 +0000
commitc76cab624763166d60251ed7df76b66547d63b61 (patch)
tree4e51e023113f7afcd62f51f9473fd7cb54a25d0c /crates/ide/src/inlay_hints.rs
parente3204c528b44ef676362d6fc27a72cac868dfbdb (diff)
parent0aaa61cd5679112a0b2e5b5c53bc9edc41d6153c (diff)
Merge #7465
7465: Only hide parameter hints for path, field and methodcall expressions r=SomeoneToIgnore a=Veykril Doing this check for other expressions makes little sense to me. Fixes #7458 Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide/src/inlay_hints.rs')
-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}