Prefer hir::SelfParam and fix signature help of methods from macros

This commit is contained in:
oxalica 2023-08-09 02:42:08 +08:00
parent 6a2f83a8a2
commit de86444756
No known key found for this signature in database
GPG key ID: D425CB23CADE82D9
3 changed files with 27 additions and 7 deletions

View file

@ -202,7 +202,7 @@ fn signature_help_for_call(
res.signature.push('(');
{
if let Some((self_param, _)) = callable.receiver_param(db) {
format_to!(res.signature, "{}", self_param)
format_to!(res.signature, "{}", self_param.display(db))
}
let mut buf = String::new();
for (idx, (pat, ty)) in callable.params(db).into_iter().enumerate() {
@ -1314,6 +1314,25 @@ id! {
);
}
#[test]
fn fn_signature_for_method_call_defined_in_macro() {
check(
r#"
macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
struct S;
id! {
impl S {
fn foo<'a>(&'a mut self) {}
}
}
fn test() { S.foo($0); }
"#,
expect![[r#"
fn foo(&'a mut self)
"#]],
);
}
#[test]
fn call_info_for_lambdas() {
check(