Skip to content

Commit 11aed78

Browse files
committed
fix: replace errors in receiver type when iterating method candidates
1 parent 009e6ce commit 11aed78

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

crates/hir/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,9 +2601,7 @@ impl Type {
26012601
) {
26022602
// There should be no inference vars in types passed here
26032603
// FIXME check that?
2604-
// FIXME replace Unknown by bound vars here
2605-
let canonical =
2606-
Canonical { value: self.ty.clone(), binders: CanonicalVarKinds::empty(&Interner) };
2604+
let canonical = hir_ty::replace_errors_with_variables(&self.ty);
26072605

26082606
let env = self.env.clone();
26092607
let krate = krate.id;

crates/ide_completion/src/completions/dot.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,4 +697,26 @@ fn f() {
697697
"#]],
698698
);
699699
}
700+
701+
#[test]
702+
fn completes_method_call_when_receiver_type_has_errors_issue_10297() {
703+
check(
704+
r#"
705+
//- minicore: iterator, sized
706+
struct Vec<T>;
707+
impl<T> IntoIterator for Vec<T> {
708+
type Item = ();
709+
type IntoIter = ();
710+
fn into_iter(self);
711+
}
712+
fn main() {
713+
let x: Vec<_>;
714+
x.$0;
715+
}
716+
"#,
717+
expect![[r#"
718+
me into_iter() (as IntoIterator) fn(self) -> <Self as IntoIterator>::IntoIter
719+
"#]],
720+
)
721+
}
700722
}

0 commit comments

Comments
 (0)