Intellij-rust: Smart autocompletion not working when nesting several `for` loops.

Created on 1 Jul 2020  路  3Comments  路  Source: intellij-rust/intellij-rust

Environment

  • IntelliJ Rust plugin version: 0.2.125.3191-201
  • Rust toolchain version: 1.44.1
  • IDE name and version: CLion 2020.1.2
  • Operating system: Windows 10

Problem description

Smart autocompletion not working when nesting several for loops. See below to reproduce issue.

Steps to reproduce

1.) Create a new fresh project in CLion:
cargo new <project-name>

2.) Create a function which contains several nested for loops:

fn process(string: String) -> HashMap<String, Vec<String>> {
    for line in string.lines() {
        for sentence in line.split_terminator('.') {
            for word in sentence.trim().split_whitespace() {
                if word.chars().nth(0).unwrap().is_uppercase() {
                    todo!()
                }
            }
        }
    }
    todo!()
}

3.) Realize that type hinting and smart code completion/suggestion works only inside the first for-loop. For the second and third for-loops, they won't work (See images below).
first-for-loop
second-for-loop
third-for-loop

bug macros type inference & name resolution

All 3 comments

@joslopgar thanks for the report!
Actually, it's not related to nested loops. Reason of completion absence is fail of type inference for line.split_terminator('.') expression. Try to enable new macro expansion engine (see #3628 for details). It should solve your issue.

Thank you for your answer @Undin ! I'm glad this is a known issue, I imagine it's been researched by now.
I tried enabling the new macro expansion engine and it worked!

Should I close the issue then? (This is my time reporting a bug, and I don't know how to proceed).

I tried enabling the new macro expansion engine and it worked!

Glad to hear it!

Should I close the issue then?

No. We will close all issues that are fixed by new macro expansion engine (like this one) after it becomes default option (I hope quite soon)

Was this page helpful?
0 / 5 - 0 ratings