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 <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-01-27 14:40:57 +00:00 committed by GitHub
commit c76cab6247
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -416,8 +416,11 @@ fn get_string_representation(expr: &ast::Expr) -> Option<String> {
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
);
}"#,
)
}
}