From: Lukas Wirth Date: Mon, 8 Nov 2021 13:10:26 +0000 (+0100) Subject: Add test for current incorrect behaviour X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=f7e8136923170bde35540207bdb5b9075204c854;p=rust.git Add test for current incorrect behaviour --- diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 8fae06f7e24..ac01968126d 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -598,7 +598,8 @@ fn expected_type_and_name(&self) -> (Option, Option) { .map(|c| (Some(c.return_type()), None)) .unwrap_or((None, None)) }, - ast::Stmt(_it) => (None, None), + ast::ParamList(__) => (None, None), + ast::Stmt(__) => (None, None), ast::Item(__) => (None, None), _ => { match node.parent() { @@ -1174,4 +1175,23 @@ fn foo() { expect![[r#"ty: Foo, name: ?"#]], ); } + + #[test] + fn expected_type_param_pat() { + check_expected_type_and_name( + r#" +struct Foo { field: u32 } +fn foo(a$0: Foo) {} +"#, + expect![[r#"ty: Foo, name: ?"#]], + ); + check_expected_type_and_name( + r#" +struct Foo { field: u32 } +fn foo($0: Foo) {} +"#, + // FIXME make this work, currently fails due to pattern recovery eating the `:` + expect![[r#"ty: ?, name: ?"#]], + ); + } }