about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDawer <7803845+iDawer@users.noreply.github.com>2021-09-27 21:44:27 +0500
committerDawer <7803845+iDawer@users.noreply.github.com>2021-09-27 21:46:00 +0500
commit11aed78e2b0aa573f152a2159ae3525b01c9581d (patch)
tree9a2f0e275223b21a8a09fa57a109a67cd1faff4d
parent009e6ceb1ddcd27a9ced3bcb7d0ef823379185a1 (diff)
downloadrust-11aed78e2b0aa573f152a2159ae3525b01c9581d.tar.gz
rust-11aed78e2b0aa573f152a2159ae3525b01c9581d.zip
fix: replace errors in receiver type when iterating method candidates
-rw-r--r--crates/hir/src/lib.rs4
-rw-r--r--crates/ide_completion/src/completions/dot.rs22
2 files changed, 23 insertions, 3 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 99ab630a300..a28e93d53b0 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -2601,9 +2601,7 @@ impl Type {
     ) {
         // There should be no inference vars in types passed here
         // FIXME check that?
-        // FIXME replace Unknown by bound vars here
-        let canonical =
-            Canonical { value: self.ty.clone(), binders: CanonicalVarKinds::empty(&Interner) };
+        let canonical = hir_ty::replace_errors_with_variables(&self.ty);
 
         let env = self.env.clone();
         let krate = krate.id;
diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs
index 94a5ebabf9b..213cb701704 100644
--- a/crates/ide_completion/src/completions/dot.rs
+++ b/crates/ide_completion/src/completions/dot.rs
@@ -697,4 +697,26 @@ fn f() {
             "#]],
         );
     }
+
+    #[test]
+    fn completes_method_call_when_receiver_type_has_errors_issue_10297() {
+        check(
+            r#"
+//- minicore: iterator, sized
+struct Vec<T>;
+impl<T> IntoIterator for Vec<T> {
+    type Item = ();
+    type IntoIter = ();
+    fn into_iter(self);
+}
+fn main() {
+    let x: Vec<_>;
+    x.$0;
+}
+"#,
+            expect![[r#"
+                me into_iter() (as IntoIterator) fn(self) -> <Self as IntoIterator>::IntoIter
+            "#]],
+        )
+    }
 }