From a5d85a6356dc761d047f46bf04eae09dc9ab80f9 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 23 May 2021 12:52:41 +0200 Subject: Add test for #8931 and better checking --- crates/ide_completion/src/completions/dot.rs | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'crates/ide_completion/src') diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs index 7e4efe589..1bff55936 100644 --- a/crates/ide_completion/src/completions/dot.rs +++ b/crates/ide_completion/src/completions/dot.rs @@ -454,4 +454,33 @@ mod foo { "#]], ); } + + #[test] + fn issue_8931() { + check( + r#" +#[lang = "fn_once"] +trait FnOnce { + type Output; +} +struct S; + +struct Foo; +impl Foo { + fn foo(&self) -> &[u8] { loop {} } +} + +impl S { + fn indented(&mut self, f: impl FnOnce(&mut Self)) { + } + + fn f(&mut self, v: Foo) { + self.indented(|this| v.$0) + } +} + "#, + expect![[r#" + "#]], + ); + } } -- cgit v1.2.3 From 34a3bc4196db302ea5b31c51b6d555336965be5f Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 23 May 2021 13:00:14 +0200 Subject: Paper over #8931 a bit more The problem was the skipping of binders in `resolve_method_call_as_callable`; this still doesn't use the _correct_ substitution, but at least it doesn't return a type with free variables in it. Fixes #8931. --- crates/ide_completion/src/completions/dot.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ide_completion/src') diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs index 1bff55936..fd9738743 100644 --- a/crates/ide_completion/src/completions/dot.rs +++ b/crates/ide_completion/src/completions/dot.rs @@ -480,6 +480,7 @@ impl S { } "#, expect![[r#" + me foo() fn(&self) -> &[u8] "#]], ); } -- cgit v1.2.3