fix: replace errors in receiver type when iterating method candidates

This commit is contained in:
Dawer 2021-09-27 21:44:27 +05:00
parent 009e6ceb1d
commit 11aed78e2b
2 changed files with 23 additions and 3 deletions

View file

@ -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;

View file

@ -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
"#]],
)
}
}