From 0aaa61cd5679112a0b2e5b5c53bc9edc41d6153c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 27 Jan 2021 14:20:58 +0100 Subject: Only hide parameter hints for path, field and methodcall expressions --- crates/ide/src/inlay_hints.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'crates') 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 { name_ref => Some(name_ref.to_owned()), } } + ast::Expr::FieldExpr(field_expr) => Some(field_expr.name_ref()?.to_string()), + ast::Expr::PathExpr(path_expr) => Some(path_expr.to_string()), + ast::Expr::PrefixExpr(prefix_expr) => get_string_representation(&prefix_expr.expr()?), ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?), - _ => Some(expr.to_string()), + _ => None, } } @@ -1438,4 +1441,19 @@ fn main() { "#, ) } + + #[test] + fn param_name_hints_show_for_literals() { + check( + r#"pub fn test(a: i32, b: i32) -> [i32; 2] { [a, b] } +fn main() { + test( + 0x0fab272b, + //^^^^^^^^^^ a + 0x0fab272b + //^^^^^^^^^^ b + ); +}"#, + ) + } } -- cgit v1.2.3