Strange imports behavior with Rust


My CLion with Rust plugin has suddenly started misbehaving.

When I comment out code temporarily, the IDE automatically removes the use… statement at the top of the file. This is a pain because I have to re-add it constantly.

More annoyingly, there is one particular file where if I make even a small edit, the IDE automatically re-adds use statements at the top, yielding duplicates.

I haven't narrowed down the problem with that one particular file. I suspect it has something to do with associated types in a trait, or maybe borrow_mut(). I'm happy to send the entire file if someone wants it.

In the short term, though, is there a switch I can turn this bad behavior off? (It's clearly a bug). A search for “import” in Settings doesn't yield anything. It shows “Import out-of-scope items on completion” and “Insert imports on paste”, both of which I want.






Just for the record: the user has also contacted support via Help | Contact Support in the IDE, and the support team is communicating with them.


Do you have “Optimize imports” set in Tools > Actions on Save?  If so, turn it off.