Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/dot.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/dot.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/crates/ide-completion/src/completions/dot.rs b/crates/ide-completion/src/completions/dot.rs index d12654665c..0557265f23 100644 --- a/crates/ide-completion/src/completions/dot.rs +++ b/crates/ide-completion/src/completions/dot.rs @@ -89,7 +89,7 @@ pub(crate) fn complete_dot( acc.add_method(ctx, dot_access, func, None, None) }); - if ctx.config.enable_auto_iter { + if ctx.config.enable_auto_iter && !receiver_ty.strip_references().impls_iterator(ctx.db) { // FIXME: // Checking for the existence of `iter()` is complicated in our setup, because we need to substitute // its return type, so we instead check for `<&Self as IntoIterator>::IntoIter`. @@ -1505,4 +1505,28 @@ fn main() { "#]], ); } + + #[test] + fn no_iter_suggestion_on_iterator() { + check_no_kw( + r#" +//- minicore: iterator +struct MyIter; +impl Iterator for MyIter { + type Item = (); + fn next(&mut self) -> Option<Self::Item> { None } +} + +fn main() { + MyIter.$0 +} +"#, + expect![[r#" + me by_ref() (as Iterator) fn(&mut self) -> &mut Self + me into_iter() (as IntoIterator) fn(self) -> <Self as IntoIterator>::IntoIter + me next() (as Iterator) fn(&mut self) -> Option<<Self as Iterator>::Item> + me nth(…) (as Iterator) fn(&mut self, usize) -> Option<<Self as Iterator>::Item> + "#]], + ); + } } |