Skip to content

Commit 629db28

Browse files
bors[bot]iDawer
andauthored
Merge #10373
10373: fix: `into_iterator` not completed on `Vec<{unknown}>` r=iDawer a=iDawer Fixes #10297 Co-authored-by: Dawer <[email protected]>
2 parents cd9f27d + f222665 commit 629db28

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

crates/hir/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,9 +2504,8 @@ impl Type {
25042504

25052505
pub fn autoderef<'a>(&'a self, db: &'a dyn HirDatabase) -> impl Iterator<Item = Type> + 'a {
25062506
// There should be no inference vars in types passed here
2507-
// FIXME check that?
2508-
let canonical =
2509-
Canonical { value: self.ty.clone(), binders: CanonicalVarKinds::empty(&Interner) };
2507+
let ty = hir_ty::replace_errors_with_variables(&self.ty).value;
2508+
let canonical = Canonical { value: ty, binders: CanonicalVarKinds::empty(&Interner) };
25102509
let environment = self.env.env.clone();
25112510
let ty = InEnvironment { goal: canonical, environment };
25122511
autoderef(db, Some(self.krate), ty)
@@ -2600,10 +2599,7 @@ impl Type {
26002599
callback: &mut dyn FnMut(&Ty, AssocItemId) -> ControlFlow<()>,
26012600
) {
26022601
// There should be no inference vars in types passed here
2603-
// FIXME check that?
2604-
// FIXME replace Unknown by bound vars here
2605-
let canonical =
2606-
Canonical { value: self.ty.clone(), binders: CanonicalVarKinds::empty(&Interner) };
2602+
let canonical = hir_ty::replace_errors_with_variables(&self.ty);
26072603

26082604
let env = self.env.clone();
26092605
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)